Template template code is not working
c++, templates
Solution
You need to mark `Pattern_Type::traits` as a template:
A<Pattern_Type::template traits> a;
This is needed because it is dependent on the template parameter `Pattern_Type`.
You also shouldn't use `typename` there because `traits` is a template, not a type.
Problem
I'm using gcc/4.7 and I need to instantiate a class with a template-template argument in a template function (or member function). I receive the following error ``` test.cpp: In function 'void setup(Pattern_Type&)': test.cpp:17:34: error: type/value mismatch at argument 1 in template parameter list for 'template<template<class> class C> struct A' test.cpp:17:34: error: expected a class template, got 'typename Pattern_Type::traits' test.cpp:17:37: error: invalid type in declaration before ';' token test.cpp:18:5: error: request for member 'b' in 'a', which is of non-class type 'int' ``` By commenting the two lines marked in the snippet the code runs, so A a can be instantiated in 'main' but not in 'setup'. I think this would be of interest also for others, and I would be really happy to understand the reason why the code does not work. Here's the code ``` struct PT { template <typename T> struct traits { int c; }; }; template <template <typename> class C> struct A { typedef C<int> type; type b; }; template <typename Pattern_Type> void setup(Pattern_Type &halo_exchange) { A<typename Pattern_Type::traits> a; // Line 17: Comment this a.b.c=10; // Comment this } int main() { A<PT::traits> a; a.b.c=10; return 0; } ``` Thanks for any suggestion and fix! Mauro