Checking function parameters in Phobos

Marco Leise Marco.Leise at gmx.de
Tue Nov 26 16:06:32 PST 2013


Am Mon, 25 Nov 2013 14:01:28 +0100
schrieb Simen Kjærås <simen.kjaras at gmail.com>:

> On 2013-11-25 13:00, Marco Leise wrote:
> > Can you write a templated assignment operator that
> > accepts any Validated!* instance and builds the set difference
> > of validation functions that are missing on the assigned value?
> > E.g. in the case of n = i: {isPositive} / {isPositive,
> > lessThan42} = emtpy set.
> 
> Do you mean this?
> 
> Validated!(int, isPositive, lessThan42) a =
>      validated!(isPositive, lessThan42)(13);
> Validated!(int, isPositive) b = a;
> a = b; // Only tests lessThan42
> 
> If so, you're mostly right that this should be done. I am however of the 
> opinion that conversions that may throw should be marked appropriately, 
> so this will be the right way:
> 
> a = validated!(isPositive, lessThan42)(b); // Only tests lessThan42
> 
> New version now available on GitHub:
> http://git.io/hEe0MA
> http://git.io/QEP-kQ
> 
> --
>    Simen

Yes, that is what I had in mind.

-- 
Marco



More information about the Digitalmars-d mailing list