I have a template statistics class that has range parameters.
template <typename T>
class limitStats
{
public:
limitStats(T mx, T min) :
max(mx),
min(mn),
range(mx-mn)
{;}
private:
const T max;
const T min;
const T range;
}
I would like to put default values of maximum and minimum allowable values, but the minimum value is not the same for floating point and integer types.
Normally I can write
T min_val = numeric_limits<T>::isinteger ? numeric_limits<T>::min() : -numeric_limits<T>::max();
I have found that I can't use it as a default parameter
limitStats(T mx = std::numeric_limts<T>::max(),
T mn = numeric_limits<T>::isinteger ? numeric_limits<T>::min() : -numeric_limits<T>::max())
Is there a way of achieving something like this?