]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - test/CXX/temp/temp.decls/temp.class.spec/p6.cpp
Update clang to r86025.
[FreeBSD/FreeBSD.git] / test / CXX / temp / temp.decls / temp.class.spec / p6.cpp
1 // RUN: clang-cc -fsyntax-only -verify %s
2
3 // Test class template partial specializations of member templates.
4 template<typename T>
5 struct X0 {
6   template<typename U> struct Inner0 {
7     static const unsigned value = 0;
8   };
9   
10   template<typename U> struct Inner0<U*> { 
11     static const unsigned value = 1;
12   };
13 };
14
15 template<typename T> template<typename U>
16 struct X0<T>::Inner0<const U*> {
17   static const unsigned value = 2;
18 };
19
20 int array0[X0<int>::Inner0<int>::value == 0? 1 : -1];
21 int array1[X0<int>::Inner0<int*>::value == 1? 1 : -1];
22 int array2[X0<int>::Inner0<const int*>::value == 2? 1 : -1];
23
24 // Make sure we can provide out-of-line class template partial specializations
25 // for member templates (and instantiate them).
26 template<class T> struct A { 
27   struct C {
28     template<class T2> struct B;
29   };
30 };
31
32 // partial specialization of A<T>::C::B<T2> 
33 template<class T> template<class T2> struct A<T>::C::B<T2*> { }; 
34
35 A<short>::C::B<int*> absip;
36
37 // Check for conflicts during template instantiation. 
38 template<typename T, typename U>
39 struct Outer {
40   template<typename X, typename Y> struct Inner;
41   template<typename Y> struct Inner<T, Y> {}; // expected-note{{previous}}
42   template<typename Y> struct Inner<U, Y> {}; // expected-error{{cannot be redeclared}}
43 };
44
45 Outer<int, int> outer; // expected-note{{instantiation}}
46
47 // Test specialization of class template partial specialization members.
48 template<> template<typename Z>
49 struct X0<float>::Inner0<Z*> {
50   static const unsigned value = 3;
51 };
52
53 int array3[X0<float>::Inner0<int>::value == 0? 1 : -1];
54 int array4[X0<float>::Inner0<int*>::value == 3? 1 : -1];
55 int array5[X0<float>::Inner0<const int*>::value == 2? 1 : -1];