I have created an ordinary class with a templated method, and all the method instances are explicit and inlined.
Like
class MyClass
{
template<int N> inline void MyMethod();
template<> inline void MyMethod<1>() { cout << 1; }
template<> inline void MyMethod<2>() { cout << 2; }
};
I needed to use the template<>
syntax to have it compile. I tried other solutions, such as the explicit definition of the method outside the class declaration, with syntax variants, to no avail. (This was made under VS2008, not tried on later versions.)
I have two questions:
- is this portable ?
- does it make sense ?