For the new std.variant
Robert Jacques
sandford at jhu.edu
Mon Oct 31 23:51:21 PDT 2011
On Mon, 31 Oct 2011 06:30:40 -0400, Steve Teale <steve.teale at britseyeview.com> wrote:
> Robert,
>
> Maybe you can fix this along the way:
>
> import std.variant;
> struct B
> {
> int p, q, r, s;
> }
> typedef B C;
>
> void main()
> {
> B b;
> C c;
> b = c; // ok
> Variant v = c;
> assert(v.convertsTo!(B)); // no dice
> }
>
> Steve
As others have mentioned, typedef is being deprecated. That said, variant now supports duck-typing. So 'v.to!B()' works. However, 'convertsTo's mandate is to test for implicit conversion, which isn't covered as there's no way in __traits to recover a typedef's base type.
More information about the Digitalmars-d
mailing list