S
Stuart Redmann
Hello newsgroup,
just out of curiosity I had a look at the implementation of <limits> (in
hope of not being OT, I use MS VC 6.0). For those who don't have it, I
feel free to cite it here:
(the following lines are from VC98/include/limits)
template<class _Ty> class numeric_limits : public _Num_base {
public:
static _Ty (__cdecl min)() _THROW0()
{return (_Ty(0)); }
static _Ty (__cdecl max)() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl epsilon() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl round_error() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl denorm_min() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl infinity() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl quiet_NaN() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl signaling_NaN() _THROW0()
{return (_Ty(0)); }
};
As you can see, this template class gives us a kind of standard
implementation of the methods. Note also, that this standard
implementation is pretty useless.
My question is: Is there a good reason why numeric_limits should be
implemented this way? Wouldn't it be more reasonable to leave these
methods out of the template definition? As I see it, only
specializations of this template are actually used, so even deriving the
template numeric_limits from _Num_base is quite useless (the
specializations of this template aren't forced to derive from _Num_base
this way, are they?)
Thanks,
Stuart
just out of curiosity I had a look at the implementation of <limits> (in
hope of not being OT, I use MS VC 6.0). For those who don't have it, I
feel free to cite it here:
(the following lines are from VC98/include/limits)
template<class _Ty> class numeric_limits : public _Num_base {
public:
static _Ty (__cdecl min)() _THROW0()
{return (_Ty(0)); }
static _Ty (__cdecl max)() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl epsilon() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl round_error() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl denorm_min() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl infinity() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl quiet_NaN() _THROW0()
{return (_Ty(0)); }
static _Ty __cdecl signaling_NaN() _THROW0()
{return (_Ty(0)); }
};
As you can see, this template class gives us a kind of standard
implementation of the methods. Note also, that this standard
implementation is pretty useless.
My question is: Is there a good reason why numeric_limits should be
implemented this way? Wouldn't it be more reasonable to leave these
methods out of the template definition? As I see it, only
specializations of this template are actually used, so even deriving the
template numeric_limits from _Num_base is quite useless (the
specializations of this template aren't forced to derive from _Num_base
this way, are they?)
Thanks,
Stuart