casts / wildcards for parametrized types

Meta jared771 at gmail.com
Thu Aug 1 17:45:15 PDT 2013


On Friday, 2 August 2013 at 00:44:21 UTC, Meta wrote:
> One more way, not necessarily a workaround but a little trick 
> that doesn't require you to know the exact type of box, is to 
> use typeof(box).
>
> auto box = Box!int();
> auto item = cast(Item)box;
> auto box2 = cast(typeof(box));

Whoops, make that last line:

auto box2 = cast(typeof(box))item;


More information about the Digitalmars-d-learn mailing list