std.contracts.enforceEx

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Mon Feb 8 04:56:03 PST 2010


Steve Teale wrote:
> Perhaps a bug? If this is written as a normal function template it seems 
> to work the same way, but has the advantage of generating better Ddoc 
> information. That is:
> 
> T enforceEx(E, T)(T value, lazy string msg = "")
> {
>     if (!value) throw new E(msg);
>         return value;
> }
> 
> instead of:
> 
> template enforceEx(E)
> {
>     T enforceEx(T)(T value, lazy string msg = "")
>     {
>         if (!value) throw new E(msg);
>         return value;
>     }
> }

The function was indeed written that way to navigate around a limitation.

Andrei



More information about the Digitalmars-d mailing list