Re: Type safety, C++ and code generation



REH wrote:

your logic is also flawed in that it will
not detect overflows

Because it's not within the responsibilities of the class that is supposed to implement ranges.
The overflow is what happens (or not!) on the level of the underlying type.

If this has the overflow problems:

typedef range<int, 0, 100> R;

then the solution to those problems is this:

typedef range<my_int_with_overflow_protection, 0, 100> R;

or this:

typedef range<big_int, 0, 100> R;

or even this:

typedef range<overflow_protected<int>, 0, 100> R;

and so on - but whatever it is, it's not within the responsibilities of the range<T> class, which is only supposed to implement ranges on top of some given underlying type.


--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
.