Ranged Numeric Types in C++

I've started writing a simple template class for automating range checking in specialized numeric types, inspired by the ranged types in languages such as Pascal and Ada. At the moment it is mainly meant for integer types, though I've made it flexible enough that it should work with floating-point types (I may need to revisit this later).

It is just a stub at this point, but it should make it easier to define numeric types which don't fit the usual 8/16/32/64 bit signed and unsigned sizes. It allow the client-programmer to select a base type define both a lower and an upper bound, and define how it should behave on either underflow or overflow (with the choices at the moment being to wrap around; to saturate at the boundary; or to throw an exception). The usual arithmetic operators will all be supported.

The question I have is this: is this really a useful class to write, and will others find it useful enough that it is worth providing publicly? Can you think of use cases where this would make things easier for someone working on a real-world project?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.