to!() conversion between objects
Piotr Szturmaj
bncrbme at jadamspam.pl
Wed Oct 19 10:47:55 PDT 2011
I have written a simple conversion template for tuples, structs and classes:
https://gist.github.com/1299046
The problem is that it may conflict with to!Class1(Class2) template.
This template does dynamic cast and throw exception when the target is
null and source is non null. Why implement that in std.conv? Why not
enforce(cast(Class1)Class2_object) or maybe create something like
DynamicCast!T?
Currently, in my private repo I added a constraint so dynamic cast
template is chosen only if tupleof lengths are different. If they are
the same then conversion is performed on each field, but I think it may
be sometimes ambiguous.
Is that field-by-field conversion welcome in Phobos at all?
Thanks
More information about the Digitalmars-d
mailing list