I have this simple code:
template<template <class> class Generator>
class TestHelper {};
template<class Writer>
class Test
{
typedef TestHelper< Test > Helper;
};
It’s works great on last g++ versions, but, in 4.4 or 4.5, I get this error:
test.cpp:7: error: type/value mismatch at argument 1 in template parameter list for 'template<template<class> class Generator> class TestHelper'
test.cpp:7: error: expected a class template, got 'Test<Writer>'
What I’m doing wrong?
It’s because inside the body of class
Test<Writer>, namingTestwithout providing the template arguments automatically assumes the same arguments (e.g.Writer).For example, this allows you to write the copy constructor as:
instead of
You can overcome this by qualifying
Testwith its namespace, e.g.NOTE: As Tomalek suggests, the original usage is valid in C++0x. Here is the relevant paragraph of the standard (emphasis mine), from section 14.6.1 (
[temp.local]):