I have the following class template:
template<typename T, T n> class Some
{
public:
Some() : v(n) {}
T get() const { return v ; }
private:
T v;
};
I happily can specialize on an int, just like:
template <>
class Some<int, 0>
{
public:
Some() : v(0) {}
int get() const {return v;}
private:
int v;
};
However if I try to make the same with float
:
template <>
class Some<float, 0>
{
public:
Some() : v(0) {}
float get() const {return v;}
private:
float v;
};
I get ugly compilation errors:
error: 'float' is not a valid type for a template non-type parameter
class Some<float, 0>
^
Why? And how can I make the class work for float
s also?