to!() conversion between objects

Piotr Szturmaj bncrbme at jadamspam.pl
Wed Oct 19 11:16:31 PDT 2011


bearophile wrote:
> Piotr Szturmaj:
>
>> I have written a simple conversion template for tuples, structs and classes:
>
> Do you have some use case to show me?

class C
{
     int i;
     string s;
}

struct S
{
     string s;
     float f;
}

auto c = to!C(S("5", 2.5f));
assert(c.i == 5 && c.s == "2.5");


More information about the Digitalmars-d mailing list