Explicit and partial template specialization nested in classes.

P

Patrick Kowalzick

Dear all,

the following code is illegeal (but compiles with MSVC 7.1):

// *** illegal ***
struct outer0 {
template<typename inner_var>
struct inner { };

template<>
struct inner<void> { };
};
// ***

but is the following legal (compiles with g++, comeau, MSVC7.1) ?

// *** legal ***
struct outer0 {
template<typename inner_var, typename hack = void>
struct inner { };

template<typename hack>
struct inner<void,hack> { };
};
// ***

Example copied from:
http://lists.debian.org/debian-gcc/2004/09/msg00015.html

There I found as well:
In an explicit specialization declaration for a member of a class
template or a member template that appears in namespace scope, the
member template and some of its enclosing class templates may remain
unspecialized, except that the declaration shall not explicitly
specialize a class member template if its enclosing class templates
are not explicitly specialized as well.

but it does not tell if its legal :(.

Regards,
Patrick
 

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