p5-example.cpp revision 175c5bb2b09217df71319cb3d58b3c511fd04138
1// RUN: %clang_cc1 -fsyntax-only -verify %s 2template<class T> struct A { 3 struct B { }; 4 template<class U> struct C { }; 5}; 6 template<> struct A<int> { 7 void f(int); 8}; 9void h() { 10 A<int> a; 11 a.f(16); 12} 13// A<int>::f must be defined somewhere 14// template<> not used for a member of an // explicitly specialized class template 15void A<int>::f(int) { /* ... */ } 16 template<> struct A<char>::B { 17 void f(); 18}; 19// template<> also not used when defining a member of // an explicitly specialized member class 20void A<char>::B::f() { /* ... */ } 21 template<> template<class U> struct A<char>::C { 22 void f(); 23}; 24 25template<> 26template<class U> void A<char>::C<U>::f() { /* ... */ } 27 template<> struct A<short>::B { 28 void f(); 29}; 30template<> void A<short>::B::f() { /* ... */ } // expected-error{{no function template matches function template specialization 'f'}} 31 template<> template<class U> struct A<short>::C { 32 void f(); 33}; 34template<class U> void A<short>::C<U>::f() { /* ... */ } // expected-error{{template parameter list matching the non-templated nested type 'A<short>' should be empty ('template<>')}} 35