Fun with templates

TommiT tommitissari at hotmail.com
Sat Jul 6 04:23:07 PDT 2013


On Saturday, 6 July 2013 at 10:34:04 UTC, Manu wrote:
> I'm getting the distinct feeling that what I want is not 
> actually possible.
> Which I have to say, is rather surprising.

This seems like a defect of the language. Perhaps a new language 
feature is needed. Something like this:

void foo(inout T)(T t)
{
     t.mutate();
}

Pass a variable of type S, const(S), or mutable(S), and the 
function signature becomes:

void foo(S);

And then fails if your argument cannot be converted to mutable S.


More information about the Digitalmars-d mailing list