Support implicit conversion between types

Adam D. Ruppe destructionator at gmail.com
Wed Sep 4 13:46:59 PDT 2013


On Wednesday, 4 September 2013 at 20:25:28 UTC, ilya-stromberg 
wrote:
> So, the question is: what should I add to "Foo" struct to allow 
> implicit conversions from "int" to "Foo"?

D does not support implicit struct construction.

Interestingly though, it *does* support it for functions taking 
classes:

class Foo {
         this(int i) {}
}

void foo(Foo f...) {}

void main() {
         foo(10);
}


But there's nothing like it for structs.


More information about the Digitalmars-d-learn mailing list