D2 cast away const

Frank Benoit keinfarbton at googlemail.com
Mon Nov 5 09:01:50 PST 2007


Is there a way to make a generic T const free?

E.g. there is this function:

T[] reverse(T)(T[] str ){...}

auto res1 = reverse( "abc".dup ); // T=char
auto res2 = reverse( "abc" );     // T=invariant(char)

If reverse now needs a mutable T in its implementation, how can it be
implemented?
Without explicitely testing for the known types char/wchar/dchar?



More information about the Digitalmars-d mailing list