I'm having difficulty defining and specializing a member function update()
of an inner class Outer<T1>::Inner
that is templated on a non-type (enum) argument.
#include <cstdlib>
template<typename T1>
struct Outer
{
struct Inner
{
enum Type{ A , B , C };
template<Type T2>
void update();
};
};
// Definition
template<typename T1>
template<Outer<T1>::Inner::Type T2>
void Outer<T1>::Inner::update()
{
}
// Specialization
template<typename T1>
template<Outer<T1>::Inner::A >
void Outer<T1>::Inner::update()
{
}
int main()
{
return EXIT_SUCCESS;
}
I'm getting the following error message in GCC 4.5.3
prog.cpp:17:28: error: ‘Outer::Inner::Type’ is not a type
prog.cpp:18:6: error: prototype for ‘void Outer<T1>::Inner::update()’ does not match any in class ‘Outer<T1>::Inner’
prog.cpp:11:15: error: candidate is: template<class T1> template<Outer<T1>::Inner::Type T2> void Outer<T1>::Inner::update()
prog.cpp:24:28: error: ‘Outer::Inner::A’ is not a type
prog.cpp:25:6: error: prototype for ‘void Outer<T1>::Inner::update()’ does not match any in class ‘Outer<T1>::Inner’
prog.cpp:11:15: error: candidate is: template<class T1> template<Outer<T1>::Inner::Type T2> void Outer<T1>::Inner::update()
BTW, unlike GCC, Visual Studio 2008 is unable to compile the following
template<typename T1>
struct Outer
{
struct Inner
{
enum Type{ A , B , C };
template<Type T2>
struct Deep;
};
};
template<typename T1>
template<typename Outer<T1>::Inner::Type T2>
struct Outer<T1>::Inner::Deep
{
};
error C2244: 'Outer<T1>::Inner::update' : unable to match function definition to an existing declaration, definition 'void Outer<T1>::Inner::update(void)', existing declarations :'void Outer<T1>::Inner::update(void)'
The striking difference between the existing and desired declarations is so obvious, isn't it =P – Estrenstruct Deep<T2>
if the enum is not in class scope. – Jaynejaynell