I am using gcc / 4.7 and I need to create an instance of the class with the template template argument in the template function (or member function). I get 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'
After commenting on the two lines marked in the code fragment, the code is executed, so A a can be created in "main", but not in "setup". I think it will be interesting for others as well, and I would be very happy to understand the reason why the code does not work. Here is 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;
Thanks for any suggestion and fix! Mauro
source share