Checking function parameters in Phobos
Jacob Carlborg
doob at me.com
Wed Nov 20 23:38:35 PST 2013
On 2013-11-21 01:16, Simen Kjærås wrote:
> The result of re-validating is performance loss. The result of missed
> validation is a bug. Also, in just a few lines, you can make a version
> that will *not* decay to the original type:
>
> struct Validated(alias fn, T) {
> private T _value;
> @property inout
> T value() {
> return _value;
> }
> }
>
> // validated() is identical to before.
>
> Sure, using it is a bit more verbose than using the unadorned type,
> which is why I chose to make the original version automatically decay.
> This is a judgment where sensible people may disagree, even with
> themselves on a case-by-case basis.
It's still accessible via "value".
--
/Jacob Carlborg
More information about the Digitalmars-d
mailing list