Re: Template type parameter problem
nassim.bouayad.agha@gmail.com wrote:
Hello,
I have a problem with templates (using VC6.0) :
template <class NumericType,bool UseMin,NumericType Min,bool
UseMax,NumericType Max>
class NumericRange
{
public:
NumericRange()
{
mUseMin = UseMin;
mMin = Min;
mUseMax = UseMax;
mMax = Max;
}
protected:
NumericType mValue;
bool mUseMin;
NumericType mMin;
bool mUseMax;
NumericType mMax;
}
If I instanciate :
NumericRange<double,true,-90,true,90> c1;
NumericRange<double,true,-180,true,180> c2;
This program is illegal and shouldn't compile. One can't use floating
point type for non-type template parameters.
Since you copy the boundaries to member variables anyway, why not just
template <class NumericType>
class NumericRange {
public:
NumericRange(bool UseMin,NumericType Min,bool UseMax,NumericType
Max);
};
--
With best wishes,
Igor Tandetnik
With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925