0
template<typename T, T MIN , T MAX>
struct Range
{
    const T min;
    const T max;
    Range():min(MIN),max(MAX){};
};

template<>
struct Range<float32, MIN, MAX>
{
    typedef float32 T;
    const T min;
    const  T max;
    inline Range():min(MIN),max(MAX){};
};

struct InvalidObject
{
      const Range<uint8, 0U ,2U> numOfPoints ;
};

I want to make template to range parameters of InvalidObject same as shown in struct InvalidObject. Compiler error in this struct struct Range<float32, MIN, MAX> i want to do this because i cannot make instantiation on range template with float. Please advice if this applicable .

  • 2
    Floating point types are not allowed as non-type template parameters, only integrals. IIRC, C++20 will allow them tho. – Timo Apr 16 '20 at 12:54
  • I'm not an expert, but I'd expect this to require something like `template struct Range`, since otherwise I think `MIN` and `MAX` are undefined. (Even after assuming that we can use floating point non-type arguments.) – chi Apr 16 '20 at 13:07

0 Answers0