Implicit string lit conversion to wstring/dstring

Nick Sabalausky a at a.a
Wed Mar 14 11:35:27 PDT 2012


"Dmitry Olshansky" <dmitry.olsh at gmail.com> wrote in message 
news:jjqnnj$1j86$1 at digitalmars.com...
>
> How about this (untested)?
>
> void func()(dstring s) {
> dstring t = s;
> //... funcImpl(t);
> }
> void func(S)(S s) {
> dstring t = to!dstring(s);
> //... funcImpl(t);
> }
>

That fails to compile when passed a dstring because it matches both 
functions. Adding an "if(!is(S==dstring))" constraint to the second makes it 
compile, but then func("abc") just calls the second one instead of the 
first.




More information about the Digitalmars-d mailing list