I have code that boils down to this:
//Just a templated array class .. implementation doesn't matter
template<int N>
struct Array {};
//A simple Traits like class
template<typename T>
struct MyTraits {}
//Specialization of the traits class
template<int N>
struct Foo< Array<N> >
{
static void monkey() {};
}
int main()
{
Foo< Array<3> >::monkey();
}
Unfortunately the compiler doesn’t like it…
test.cpp: In function ‘int main()’:
test.cpp|17| error: ‘monkey’ is not a member of ‘Foo<Array<3> >’
What am I doing wrong, and how do I fix it?
Thanks
The following works for me:
The way you have
Foois incorrect, as you can see I changed it to match the comment. Additionally, you had a missing semicolon after the declaration ofFoo/MyTraits. Lastly, for an array class I would recommend you usesize_tas the type ofN.