Re: Help with Template-Template and Mixin Polymorphism
On 8/9/07 8:38 PM, in article
1186686481.872094.250620@z24g2000prh.googlegroups.com, "TimeHorse"
<darklord@timehorse.com> wrote:
Oh, as per my last post (the one with the refined code for better
understanding and the new virtual function foo, here is the
specialization I am attempting:
template <template <class, class> class X2>
struct G<typename G<X2>::G1>
{
template <class E3, class Y3>
struct G1
{
typedef X2<E3, Y3> type;
typedef typename type::key_type key_type;
typedef typename type::value_type value_type;
};
};
But microsoft VC++ 2003 is giving me a:
file(line) : error C2764: 'X2' : template parameter not used in
partial specialization 'G<G<X2>::G1>'
Error. But clearly it is, in both the specialization and the G1
typedef. Any thoughts?
Since G<X2>::G1 is the name of a template - not a type, there should be no
"typename" before G1 in the declaration of G's partial specialization.
Moreover, as a nested template name, G1 does need a "template" keyword to
precede it, informing the compiler that G1 is the name of a template.
Note that Visual C++ is quite lax about missing template and typename
keywords (and my previous post added them in your code where they were
required by the C++ Standard). And as this example shows, "template" and
"typename" really are needed in some situations for the C++ compiler to
parse a declaration.
So the correct syntax for G's partial specialization would be:
template <template <class, class> class X2>
struct G< G<X2>::template G1>
{
...
};
Greg
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]