How do I make a class whose interface matches double, but upon which templates can be specialized?

Posted by Neil G on Stack Overflow See other posts from Stack Overflow or by Neil G
Published on 2010-06-17T02:40:51Z Indexed on 2010/06/17 2:42 UTC
Read the original article Hit count: 262

Filed under:
|
|

How do I make a class whose interface matches double, but whose templated types do not dynamic cast to double?

The reason is that I have a run-time type system, and I want to be able to have a type that works just like double:

template<int min_value, int max_value>
class BoundedDouble: public double {};

And then inherit use template specialization to get run-time information about that type:

template<typename T>
class Type { etc. }

template<int min_value, int max_value>
class Type<BoundedDouble<min_value, max_value>> { int min() const { return min_value; } etc. }

But, you can't inherit from double...

© Stack Overflow or respective owner

Related posts about c++

Related posts about inheritance