Implicit conversion from string to custom type?

Tofu Ninja via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Feb 14 15:43:49 PST 2016


So I wrote a simple ref counted string type because using the 
built in strings without the GC is extremely painful. It there 
any way I can get strings to implicitly convert to my custom 
string type?

Some way to make this work...

struct rstring {...}
void fun(rstring s) {...}
...
fun("hello world"); // Currently an error

Would be super nice if it would just call the opAssign when 
trying to call fun but I suppose that has some non-obvious 
problems for why it does not work that way.


More information about the Digitalmars-d-learn mailing list