rval->ref const(T), implicit conversions
Nick Treleaven via Digitalmars-d
digitalmars-d at puremagic.com
Mon Jan 18 12:41:18 PST 2016
On Monday, 18 January 2016 at 15:36:09 UTC, Manu wrote:
> One more time...
>
> Assuming:
> void func(const CustomString &s1, const CustomString &s2);
> void func(ref const(CustomString) s1, ref const(CustomString)
> s2);
>
> C++:
> func("hello", "world");
>
> D:
> auto dumb_name = CustomString("hello");
> auto another_dumb_name = CustomString("world");
> func(dumb_name, another_dumb_name);
Seems like a template function wrapper could add the temporaries
and do implicit conversions by constructing CustomStrings from
string literals as needed by func:
manuCall!func("hello", "world");
Maybe not ideal, but better than the quoted D code.
More information about the Digitalmars-d
mailing list