// RUN: %clang_cc1 -fsyntax-only -verify %s -std=c++11 // Template argument deduction with template template parameters. template class A> struct X0 { static const unsigned value = 0; }; template class A> struct X0 { static const unsigned value = 1; }; template struct X0i; template struct X0l; int array_x0a[X0::value == 0? 1 : -1]; int array_x0b[X0::value == 1? 1 : -1]; template struct is_same { static const bool value = false; }; template struct is_same { static const bool value = true; }; template struct allocator { }; template > struct vector {}; // Fun with meta-lambdas! struct _1 {}; struct _2 {}; // Replaces all occurrences of _1 with Arg1 and _2 with Arg2 in T. template struct Replace { typedef T type; }; // Replacement of the whole type. template struct Replace<_1, Arg1, Arg2> { typedef Arg1 type; }; template struct Replace<_2, Arg1, Arg2> { typedef Arg2 type; }; // Replacement through cv-qualifiers template struct Replace { typedef typename Replace::type const type; }; // Replacement of templates template class TT, typename T1, typename Arg1, typename Arg2> struct Replace, Arg1, Arg2> { typedef TT::type> type; }; template class TT, typename T1, typename T2, typename Arg1, typename Arg2> struct Replace, Arg1, Arg2> { typedef TT::type, typename Replace::type> type; }; // Just for kicks... template class TT, typename T1, typename Arg1, typename Arg2> struct Replace, Arg1, Arg2> { typedef TT::type, Arg2> type; }; int array0[is_same::type, int>::value? 1 : -1]; int array1[is_same::type, const int>::value? 1 : -1]; int array2[is_same, int, float>::type, vector >::value? 1 : -1]; int array3[is_same, int, float>::type, vector >::value? 1 : -1]; int array4[is_same, double, float>::type, vector >::value? 1 : -1]; // PR5911 template void f(const T (&a)[N]); int iarr[] = { 1 }; void test_PR5911() { f(iarr); } // Must not examine base classes of incomplete type during template argument // deduction. namespace PR6257 { template struct X { template X(const X& u); }; struct A; void f(A& a); void f(const X& a); void test(A& a) { (void)f(a); } } // PR7463 namespace PR7463 { const int f (); template void g (T_&); // expected-note{{T_ = int}} void h (void) { g(f()); } // expected-error{{no matching function for call}} } namespace test0 { template void make(const T *(*fn)()); // expected-note {{candidate template ignored: can't deduce a type for 'T' which would make 'const T' equal 'char'}} char *char_maker(); void test() { make(char_maker); // expected-error {{no matching function for call to 'make'}} } } namespace test1 { template void foo(const T a[3][3]); void test() { int a[3][3]; foo(a); } } // PR7708 namespace test2 { template struct Const { typedef void const type; }; template void f(T, typename Const::type*); template void f(T, void const *); void test() { void *p = 0; f(0, p); } } // rdar://problem/8537391 namespace test3 { struct Foo { template static inline void foo(); }; class Bar { template static inline void wobble(T ch); public: static void madness() { Foo::foo >(); } }; } // Verify that we can deduce enum-typed arguments correctly. namespace test14 { enum E { E0, E1 }; template struct A {}; template void foo(const A &a) {} void test() { A a; foo(a); } } namespace PR21536 { template struct X; template struct S { static_assert(sizeof...(B) == 1, ""); void f() { using T = A; using T = int; using U = X; using U = X; } }; template void f(S); void g() { f(S()); } } namespace PR19372 { template class C, typename ...Us> struct BindBack { template using apply = C; }; template struct Y; template using Z = Y; using T = BindBack::apply<>; using T = Z; using U = BindBack::apply; using U = Z; }