Can someone explain why opCast is so limited?

Nathan Reed nathaniel.reed at gmail.com
Thu Sep 6 10:56:33 PDT 2007


Steven Schveighoffer wrote:
> Question #2:  Is there a way to cast a basic type to a struct/class?

D 2.0 will have an opImplicitCastFrom function, so you can write e.g.

struct myType {
     myType opImplicitCastFrom (long l) { ... }
}

This isn't implemented yet, but is planned.

Thanks,
Nathan Reed


More information about the Digitalmars-d-learn mailing list