language: C++11 (gcc-4.7.2)
date: 768 days 0 hours ago
link:
visibility: private
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#include <iostream>
 
template <int I>
struct Traits
{
  struct inner{};
};
 
template <>
struct Traits<1>
{
  struct inner{
    template<class T1>
    struct impl{
      impl() { std::cout << "impl<T1>" << std::endl; }
    };
  };
};
 
template <>
struct Traits<2>
{
  struct inner{
    template<class T1, class T2>
    struct impl{
      impl() { std::cout << "impl<T1, T2>" << std::endl; }
    };
  };
};
 
template<class T>
struct Test{};
 
template<class T, class K>
struct Foo{};
 
template<int I>
struct arg{};
 
template<
  template<class, class> class T,
  class P1, int I
>
struct Test< T<P1, arg<I> > >{
  typedef typename Traits<I>::inner inner;      
};
 
template<
  template<class, class> class T,
  class P2, int I
>
struct Test< T<arg<I>, P2 > >{
  typedef typename Traits<I>::inner inner;      
};
 
// and a bunch of other partial specializations
 
int main(){
 
  typename Test<Foo<int, arg<1> > >::inner::impl<int> a;
  typename Test<Foo<int, arg<1> > >::inner::impl<int, double> b;
  typename Test<Foo<int, arg<2> > >::inner::impl<int, double> c;
  typename Test<Foo<int, arg<2> > >::inner::impl<int> d;
}
prog.cpp: In function 'int main()':
prog.cpp:61:61: error: wrong number of template arguments (2, should be 1)
prog.cpp:14:12: error: provided for 'template<class T1> struct Traits<1>::inner::impl'
prog.cpp:61:63: error: 'b' in class 'Test<Foo<int, arg<1> > >::inner' does not name a type
prog.cpp:63:53: error: wrong number of template arguments (1, should be 2)
prog.cpp:25:12: error: provided for 'template<class T1, class T2> struct Traits<2>::inner::impl'
prog.cpp:63:55: error: 'd' in class 'Test<Foo<int, arg<2> > >::inner' does not name a type