Le 25/07/2015 09:18, Didier Kryn a écrit :
> Le 25/07/2015 01:57, Roger Leigh a écrit :
>> This really only applies to the grandfathered-in C numeric types
>> subset of C++. As soon as you use or own types (or wrap the
>> primitives), you have control over the conversions and can define
>> your own policies.
>
> Roger,
>
> This is true for the user of the class, not for the author. I mean
> the methods operating on the private part. This is typical of the C++
> philosophy: make everything possible but by hand crafting and at the
> cost of possible errors an/or unreadable source.
>
> Imagine you want to implement an integer with an allowed range [7,
> 107], you will need to embed it inside a class and provide a setter
> which raises an exception if the argument is not within the range. In
> Ada, you declare your type with its range and the compiler does the
> check for you: everywhere it cannot determine at compile-time if the
> value is in the range, it will silently insert the necessary
> instructions to verify.
>
> Didier
>