1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | template <typename T> class Foo { T x; public: Foo(T val = 0):x(val) { } }; template < template <typename T2> class T> class Bar { T2 y public: Bar(T2 val = 0):y(val) { } }; int main() { Bar<Foo<int>> b = 42; } |
dGVtcGxhdGUgPHR5cGVuYW1lIFQ+CmNsYXNzIEZvbyB7CglUIHg7CnB1YmxpYzoKCUZvbyhUIHZhbCA9IDApOngodmFsKSB7Cgl9Cn07Cgp0ZW1wbGF0ZSA8IHRlbXBsYXRlIDx0eXBlbmFtZSBUMj4KCQkgICBjbGFzcyBUPgpjbGFzcyBCYXIgewoJVDIgeQpwdWJsaWM6CglCYXIoVDIgdmFsID0gMCk6eSh2YWwpIHsgfQp9OwoKaW50IG1haW4oKQp7CglCYXI8Rm9vPGludD4+IGIgPSA0MjsKfQ==
prog.cpp:12: error: ‘T2’ does not name a type prog.cpp: In function ‘int main()’: prog.cpp:19: error: ‘>>’ should be ‘> >’ within a nested template argument list prog.cpp:19: error: type/value mismatch at argument 1 in template parameter list for ‘template<template<class T2> class T> class Bar’ prog.cpp:19: error: expected a class template, got ‘Foo<int>’ prog.cpp:19: error: invalid type in declaration before ‘=’ token prog.cpp:19: warning: unused variable ‘b’
-
result: Compilation error (maybe you wish to see an example for C++ 4.7.2)


