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));