On Tuesday, 11 February 2014 at 03:45:30 UTC, Carl Sturtivant wrote:
If I define a struct, and I want to pass a string to a function with a parameter of type that very struct, is there any way to arrange that an implicit conversion occurs, assuming a function that maps a string to that struct type exists?

Nope, you have to do it explicitly.

f(data("hello"));

You could write a wrapper function do do the conversions for you, but of course, you are still explicitly calling the wrapper at the usage site.


I kinda wish D did have this. The mistake C++ made was having the implicit conversions be the default, not having it be an option. But it isn't in and as far as I know, there are no plans to add it either.

Reply via email to