-
Notifications
You must be signed in to change notification settings - Fork 15.3k
Description
Currently, Clang doesn't accept the following code snippet, while other implementations do (demo).
template <template <typename> class>
struct B;
struct C {
template <typename>
struct Nested;
};
template <typename T>
void f(T*, B<T::template Nested>*);
void g(C *cp, B<C::template Nested>* bcnp) {
f(cp, 0);
}When 0 is replaced with {} (but not nullptr or any real null pointer constant), Clang also accept it (demo).
The following similar example is rejected by all implemenations (demo), and shows that Clang also considers that T is not deducible from B<T::template Nested>* (and thus B<T::template Nested>* forms non-deduced context for T). Although the current standard wording is possibly defective on this (see cplusplus/CWG#660).
template <template <typename> class>
struct B;
struct C {
template <typename>
struct Nested;
};
template <typename T>
void f(T*, B<T::template Nested>*);
void g(C *cp, B<C::template Nested>* bcnp) {
f({}, bcnp);
}Given that T is (or should be considered) in the non-deduced context in B<T::template Nested>*, Clang should not try to match B<T::template Nested>* against int (or std::nullptr_t), and should just take 0 (or nullptr) as null pointer constant instead.