Consider the following class:
class Foo
{
enum Flags {Bar, Baz, Bax};
template<Flags, class = void> struct Internal;
template<class unused> struct Internal<Bar, unused> {/* ... */};
template<class unused> struct Internal<Baz, unused> {/* ... */};
template<class unused> struct Internal<Bax, unused> {/* ... */};
};
The class outline above compiles and functions as expected when tested on VC++ 2010 and Comeau C++. However, when Foo
is made into a template itself, the above snippet breaks under VC++ 2010.
For example, the following snippet:
template<class> class Foo
{
// Same contents as the original non-templated Foo.
};
Yields the following error class:
C2754: 'Foo<<unnamed-symbol>>::Internal<Bar,unused>' : a partial specialization cannot have a dependent non-type template parameter
C2754: 'Foo<<unnamed-symbol>>::Internal<Baz,unused>' : a partial specialization cannot have a dependent non-type template parameter
C2754: 'Foo<<unnamed-symbol>>::Internal<Bax,unused>' : a partial specialization cannot have a dependent non-type template parameter
- Can someone explain what is going on here in plain English?
- How can I fix this (i.e., keep internal pseudo-explicit specializations in a templated
Foo
) on VC++ 2010?
Foo
is a template. I suggest you try in one of MS' newsgroups. The MS compiler folks used to hang out there. – Leach