On Tuesday, 11 February 2014 at 15:10:57 UTC, Carl Sturtivant
wrote:
D has opAssign, making defining implicit conversions from any
type to a new type possible on assignment, so where is the
analogue (say opPass) for passing an argument to a function?
void f( Data d, Data2 d2) { ..... }
void main() {
//conversions from string part of the definitions of
Data, Data2
f( "hello", "bonjour"); //no way to do this ---
disappointing
}
See
http://forum.dlang.org/thread/[email protected]
In the meanwhile maybe you can try a workaround with templates?
Something like:
void f(D1, D2)(D1 d, D2 d2) if (is(D1:Data) && is(D2 : Data2))
{
// Temp vars and assignment
...
...
f(tmpD1, tmpD2);
}