Topic: Why is partial specialziation of a nested class temp?= =?windows-1252?Q?late allowed, while complete isn t?
Author: Gunther Piez <gpiez@web.de>
Date: Tue, 30 Mar 2010 10:50:57 CST Raw View
template<int x> struct A
{
template<int y> struct B
{};.
template<int y, int unused> struct C
{};
};
template<int x> template<>
struct A<x>::B<x> {}; // error: enclosing class templates are not
explicitly specialized
template<int x> template<int unused>
struct A<x>::C<x, unused> {}; // ok
So why is the explicit specialization of a inner, nested class (or
function) not allowed, if the outer class isn't specialized too?
Strange enough, I can work around this behaviour if I only partially
specialize the inner class with simply adding a dummy template
parameter. Makes things uglier and more complex, but it works.
I would consider complete specializations as a subset of partial
specializations - especially because you can express every complete
specialization as a partial with adding a dummy parameter. So this
disambiguation between partial and full specialization doesn't really
make sense for me.
Note: I need this feature for recursive templates of the inner class
for a set of the outer class and the specialization of the inner
parameter does depend on the outer template parameter.
To make things even more complicate, in reality I only need a template
function instead of the inner template class. But partial
specialization of functions is generally disallowed somewhere else in
the standard ^^
--
[ comp.std.c++ is moderated. To submit articles, try just posting with ]
[ your news-reader. If that fails, use mailto:std-c++@netlab.cs.rpi.edu]
[ --- Please see the FAQ before posting. --- ]
[ FAQ: http://www.comeaucomputing.com/csc/faq.html ]