Nikolai Borissov wrote in news:iVGmb.10683$7t3.492363
@news20.bellglobal.com:
[color=blue]
> Is it possible to specialize a templated class defined within another
> templeted class, like below:
>
> template<typename U>
> struct A
> { template<typename T>
> struct B;
> };
>
> // Attempt to specialize internal class B for type int[/color]
I changed this to:
template <typename U> template <>
struct A<U>::B<int> {};
gcc 3.2:
test.cpp:14: enclosing class templates are not explicitly specialized
test.cpp:15: template parameters not used in partial specialization:
test.cpp:15: `U'
msvc 7.1: test.cpp:14: error C3212: 'A<U>::B<int>' : an explicit
specialization of a template member must be a member of an explicit
specialization
test.cpp:15: see declaration of 'A<U>::B<int>'
online EDG: a template declaration containing a template parameter list
may not be followed by an explicit specialization declaration
template <typename U> template <>
[color=blue]
> template<typename U>
> struct A<U>::B<int> {};
>
> typedef A<long>::B<int> MyType; // this causes a failure
>
> Online Comeau C++ fails without a message.
> What is the right syntax, if any, for such specializations ?
>[/color]
I don't think there is any.
I'd suggest switching the problem around:
template <typename T>
struct B_inner
{
template<typename U>
struct A_outer {};
};
/* Specialize this as meny times as we want
*/
template <>
struct B_inner< int >
{
template <typename U>
struct A_outer
{
};
};
template<typename U>
struct A
{
template <typename T>
struct B : public B_inner< T >::template A_outer< U >
{
};
};
typedef A<long>::B<int> MyType; // this causes a failure
HTH
Rob.
--
http://www.victim-prime.dsl.pipex.com/