// RUN: %clang_cc1 -std=c++11 -fsyntax-only -verify %s template struct value_tuple {}; template struct tuple { }; template struct pair { }; template struct value_c; template struct is_same { static const bool value = false; }; template struct is_same { static const bool value = true; }; template struct X0 { template void f(value_tuple * = 0); }; void test_X0() { X0().f<1, 2, 3, 4, 5>(); } namespace PacksAtDifferentLevels { template struct X { template struct Inner { static const unsigned value = 1; }; template struct Inner...> > { static const unsigned value = sizeof...(Types) - sizeof...(YTypes); }; }; int check0[X::Inner, pair, pair> >::value == 0? 1 : -1]; int check1[X::Inner, pair, pair> >::value == 1? 1 : -1]; template struct unsigned_tuple { }; template struct X1 { template struct Inner { static const unsigned value = 0; }; template struct Inner...>, unsigned_tuple> { static const unsigned value = 1; }; }; int check2[X1::Inner, pair, pair>, unsigned_tuple >::value == 1? 1 : -1]; int check3[X1::Inner, pair, pair>, unsigned_tuple >::value == 0? 1 : -1]; template struct X2 { template struct Inner { static const unsigned value = 1; }; template struct Inner...)> { static const unsigned value = sizeof...(Types) - sizeof...(YTypes); }; }; int check4[X2::Inner, pair, pair) >::value == 0? 1 : -1]; int check5[X2::Inner, pair, pair) >::value == 1? 1 : -1]; template struct some_function_object { template struct result_of; }; template class...> struct metafun_tuple { }; template struct X3 { template struct Inner { static const unsigned value = 0; }; template struct Inner...>, metafun_tuple::template result_of...> > { static const unsigned value = 1; }; }; int check6[X3::Inner, pair, pair>, metafun_tuple< some_function_object::result_of, some_function_object::result_of, some_function_object::result_of> >::value == 1? 1 : -1]; int check7[X3::Inner, pair, pair>, metafun_tuple< some_function_object::result_of, some_function_object::result_of, some_function_object::result_of> >::value == 0? 1 : -1]; template struct unsigned_pair { }; template struct X4 { template struct Inner { static const unsigned value = 0; }; template struct Inner...>> { static const unsigned value = 1; }; }; int check8[X4<1, 3, 5>::Inner, unsigned_pair<3, 4>, unsigned_pair<5, 6>> >::value == 1? 1 : -1]; int check9[X4<1, 3>::Inner, unsigned_pair<3, 4>, unsigned_pair<5, 6>> >::value == 0? 1 : -1]; template struct add_reference; template struct add_pointer; template struct add_const; template class ...Templates> struct X5 { template struct Inner { static const unsigned value = 0; }; template struct Inner...>> { static const unsigned value = 1; }; }; int check10[X5 ::Inner, add_pointer, add_const>>::value == 1? 1 : -1]; int check11[X5 ::Inner, add_pointer, add_const>>::value == 0? 1 : -1]; namespace PR13811 { constexpr int g(int n, int m) { return n * 10 + m; } template struct X6 { template constexpr auto f1(A ...a) const -> decltype(g(A(a + B())...)) { return g(A(a + B())...); } template constexpr auto f2(A ...a, B ...b) const -> decltype(g((&a)[b] ...)) { return g((&a)[b] ...); } // expected-note {{past-the-end}} template struct Inner { template constexpr auto f(A ...a, B ...b, C ...c) const -> decltype(g(a+b+c...)) { return g(a+b+c...); } }; }; struct A { constexpr operator int() const { return 2; } }; struct B { constexpr operator int() const { return 1; } }; static_assert(X6().f1(255, 1) == 12, ""); static_assert(X6().f2(3, 4, 0, 0) == 34, ""); static_assert(X6().f2(3, 4, 0, 1) == 34, ""); // expected-error {{constant expression}} expected-note {{in call}} static_assert(X6::Inner().f(1, 2, 3, 4, 5, 6) == 102, ""); } } namespace ExpandingNonTypeTemplateParameters { template struct tuple_of_values { template // expected-error{{a non-type template parameter cannot have type 'float'}} \ // expected-note{{template parameter is declared here}} struct apply { // expected-note 2{{template is declared here}} typedef tuple...> type; }; }; int i; float f; int check_tuple_of_values_1[ is_same::apply ::type, tuple, value_c, value_c, value_c> >::value? 1 : -1]; tuple_of_values tv1; // expected-note{{in instantiation of template class 'ExpandingNonTypeTemplateParameters::tuple_of_values' requested here}} tuple_of_values::apply::type tv2; // expected-error{{non-type template parameter of reference type 'float &' cannot bind to template argument of type 'int'}} tuple_of_values::apply::type tv3; // expected-error{{too few template arguments for class template 'apply'}} tuple_of_values::apply::type tv4; // expected-error{{too many template arguments for class template 'apply'}} } namespace ExpandingFunctionParameters { template struct X0 { typedef int type; }; template struct X1 { template typename X0::type f(U...); }; void test() { X1 x1; x1.f(17, 3.14159); } } namespace PR10230 { template struct s { template auto f() -> int(&)[sizeof...(Args)]; }; void main() { int (&ir1)[1] = s().f(); int (&ir3)[3] = s().f(); } } namespace PR13386 { template struct tuple {}; template struct S { template void f(T &&...t, U &&...u) {} // expected-note {{candidate}} template void g(U &&...u, T &&...t) {} // expected-note {{candidate}} template void h(tuple &&...) {} // expected-note 2{{candidate}} template struct X { template void x(tuple &&...); // expected-error {{different lengths}} }; }; void test() { S<>().f(); S<>().f(0); S().f(0); S().f(0, 1); S().f(0); // expected-error {{no matching member function for call}} S<>().g(); S<>().g(0); S().g(0); S().g(0, 1); // expected-error {{no matching member function for call}} S().g(0, 1); S().g(0, 1); S<>().h(); S<>().h(0); // expected-error {{no matching member function for call}} S().h({}); // expected-error {{no matching member function for call}} S().h({}); S().h(tuple{}); S().h(tuple{}, tuple{}); S::X(); // expected-note {{here}} } }