equivariant functions

Steven Schveighoffer schveiguy at yahoo.com
Mon Oct 13 13:49:39 PDT 2008


"Steven Schveighoffer" wrote
> You might be tempted to do something like this:
>
> typeof(v1) min(T)(const(T) v1, typeof(v1) v2)
>
> But then if you pass in the mutable version as the first, the function 
> fails to compile in the usage I have above.

d'oh!  A valid solution should fail to compile that usage ;)

I meant this usage (which should compile).

const(char)[] x = "bb";
x = min("aa", x);

-Steve 





More information about the Digitalmars-d mailing list