Re: Template specialisation on types nested inside templated types
On 29 Okt., 02:25, stupidalias <ci...@metropolis-data.co.uk> wrote:
gcc 4.2.0
template<typename DTYPE>
class parent
{
public:
class child {};
};
template<typename T> class tester;
template<typename DTYPE> class tester<parent<DTYPE> > {};
I strongly recommend not to use ALL_UPPER_CASE letters for
non-macro entities. Besides that the above is a normal partial
specialization.
template<typename DTYPE> class tester<typename parent<DTYPE>::child >
{};
This attempt to define such a partial specialization is not
possible, because their are no constraints on parent<>::child
at all. Consider the following specialization:
template<>
class parent<bool>
{
public:
typedef int child;
};
So, how is parent::child related to the template parameter of parent?
Or even worse, this one
template<>
class parent<double>
{}; // no child at all!
In short: There exists not a single fixed relation between
the template argument X of parent and parent<X>::child.
How do I specialise a templated type for a type nested inside another
templated type?
This cannot be done, because the inner type is not related
to the template parameter of the outer type.
HTH and Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]