Inability to explicitly specialize a template class within another non-specialized template class

J

jn

Hi everyone,

I was trying to implement a design when I've found what seems a
limitation of standard C++. I can't specialize an inner class in this
way:

template <class ARG>
template <>
class Outer<ARG>::Inner<int>
{
//...
};

Actually, I was doing something more complex, in which the explicit
specialization was not on 'int', but on Outer<ARG>, so actually I was
trying to provide an explicit specialization for the case when the
argument to the inner template matched the outer one.

I will be working around this with a kludge, performing several
fully-explicit specializations for each of he different ARG's involved
(there are only 2 now and there will be 4 or 5 later on). But, I'd like
to know whether there is any construct in C++ by which I can detect
matching template arguments and provide a specialization in that case
-- maybe that way I'd be able to use a better hack^H^H^H^H workaround.

Thanks in advance,

J
 
V

Victor Bazarov

I was trying to implement a design when I've found what seems a
limitation of standard C++. I can't specialize an inner class in this
way:

template <class ARG>
template <>
class Outer<ARG>::Inner<int>
{
//...
};

[..]

Yes, to explicitly specialise a member you need to first explicitly
specialise the outer template. That's a requirement of the language.

V
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top