Implicit type conversion of an argument when a function is called
Carl Sturtivant
sturtivant at gmail.com
Mon Feb 10 19:45:28 PST 2014
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?
struct data { ........ }
void f( data x) { .... }
void main() {
data( "hello"); //convert argument implicitly to type `data`.
}
It's possible to arrange for such an implicit conversion from an
existing type to a newly defined type during assignment, but what
about when passing an argument to a function?
More information about the Digitalmars-d-learn
mailing list