|
Boost : |
From: Dan McLeran (dan.mcleran_at_[hidden])
Date: 2005-09-15 15:33:34
I like this idea. We should keep this in mind while moving forward.
"Andrey Semashev" <andysem_at_[hidden]> wrote in message
news:dgcgp3$52u$1_at_sea.gmane.org...
>
>
> Dan McLeran wrote:
>> I've written a template class to hold a range of valid integral
>> values. My intent was to mimic Ada's ability to define a type like
>> this:
>> type SmallInt is range -10 .. 10;
>>
>> One can then declare objects of this type and any subsequent
>> assignment that violated this range constraint woud throw an
>> exception.
>> I have built a C++ template class that does the same thing:
>>
>> template<typename T, T min, T max>
>> struct CheckedIntegralValue
>>
>
> Just a small proposal. It would be nice if CheckedIntegralValue would
> chose the actual type of value itself. For example, for range -10 .. 10 it
> would use signed char, for -1000 .. 1000 signed int, and for 0 .. 300
> unsigned int. Of course, its type detecting logic should be overrideable.
> I think, it would look something like:
>
> template< signed long long min, signed long long max, typename T =
> typename auto_detected< min, max >::type, typename BoundingPolicyT =
> throw_on_overflow >
> struct CheckedIntegralValue;
>
>
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk