language: C++11 (gcc-4.7.2)
date: 496 days 23 hours ago
link:
visibility: public
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
struct A {};
struct B {};
 
template < typename Head,
           typename... Tail>
struct X : public Head,
           public Tail...
{
    X(int _i) : i(_i) { }
 
    // add copy constructor
    X(const X& other) : i(other.i) {}
 
    int i;
};
 
template < typename Head >
struct X<Head> { };
 
int main(int argc, const char *argv[])
{
    X<A, B> x(5);
    X<A, B> y(x);
 
    // This must not be leagal!
    X<B, A> z(x);
 
    return 0;
}
 
prog.cpp: In function 'int main(int, const char**)':
prog.cpp:26:16: error: no matching function for call to 'X<B, A>::X(X<A, B>&)'
prog.cpp:12:5: note: candidates are: X<Head, Tail>::X(const X<Head, Tail>&) [with Head = B, Tail = {A}, X<Head, Tail> = X<B, A>]
prog.cpp:9:5: note:                 X<Head, Tail>::X(int) [with Head = B, Tail = {A}]