I am trying to create a partly specialized member of a templated class, where the inner class's template type is the one coming from the outer class... the following:
template<typename T>
struct Num
{
template <T n>
struct VH
{
enum { value = n };
T v = value;
};
};
template <typename T> struct Num<T>::VH<0>
{
enum {value = 1};
T v = value;
};
template <typename T> struct Num<T>::VH<1>
{
enum {value = 0};
T v = value;
};
fails with
error: too few template-parameter-lists
template <typename T> struct Num<T>::VH<0>
and the following:
template <typename T> struct Num<T>::template<> VH<0>
{
enum {value = 0};
T v = value;
};
template <typename T> struct Num<T>::template<> VH<1>
{
enum {value = 1};
T v = value;
};
just does not feel right (error: expected template-id before '<' token
template <typename T> struct Num<T>::template<> VH<0>
)
and after reading explicit specialization of template class member function the following
template <typename T> template<> struct Num<T>::VH<0>
{
enum {value = 0};
T v = value;
};
template <typename T> template <> struct Num<T>::VH<1>
{
enum {value = 1};
T v = value;
};
gives the error:
error: invalid explicit specialization before '>' token
template <typename T> template<> struct Num<T>::VH<0>
^
error: enclosing class templates are not explicitly specialized
error: template parameters not used in partial specialization:
template <typename T> template<> struct Num<T>::VH<0>
^
error: 'T'
Can anyone let me know the correct syntax for this, I don't seem to be able to figure it out now ...?