[challenge] Bounded types
Andrei Alexandrescu
SeeWebsiteForEmail at erdani.org
Mon Oct 11 20:16:18 PDT 2010
On 10/11/2010 08:45 PM, Philippe Sigaud wrote:
> 2010/10/12 Denis Koroskin<2korden at gmail.com>:
>>
>> That could be as simple as:
>>
>> struct Bounded(A min, A max, T = A) { ... }
>>
>> Bounded!(0, 1) zeroOrOne; // 4 bytes because of default int
>> Bounded!(0, 1, ubyte) zeroOrOne; // 1 byte, specified explicitly
>
> Neat, this is exactly what I had in mind.
What's wrong with inferring the type from the bounds?
Andrei
More information about the Digitalmars-d
mailing list