I have a problem with a template class I have defined:
-----------------------------------------------------------------------------------------------------------------
template <typename T, T min, T max>
class Setting
{
private:
T* value;
public:
Setting() : value(NULL) {}
~Setting() {delete value;}
const T* get() const throw() {return value;}
void set(const T& value) throw(std::exception)
{
if(value < min || value max)
{
throw std::argument_exception("Error");
}
this->value = new T(value);
};
};
-----------------------------------------------------------------------
When I try to define this:
Setting<double, 0.0, 1.0myVal1;
the compiler tells me:
error C2993: 'double' : illegal type for non-type template parameter
'min'
error C2993: 'double' : illegal type for non-type template parameter
'max'
While if I write:
Setting<unsigned int, 1, UINT_MAX, true, truemyVal2;
it works without errors.
Why?