<div dir="ltr"><div style="font-size:12.8000001907349px">Suppose I have:</div><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">import std.range;<br></div><span style="font-size:12.8000001907349px">auto a=iota(complex_expr_returning_</span><span style="font-size:12.8000001907349px">3());</span><div style="font-size:12.8000001907349px"><br></div><div style="font-size:12.8000001907349px">I'd like to have a function/trait/template/compiler magic that takes variable a and generates a string that can be mixed in to represent the type of a. The difficulty is that typeid(a).to!string doesn't work for Voldermort types:<div>typeid(a).to!string produces "std.range.iota!(int, int).iota.Result", which is not very useful as it can't be mixed in a program, being a voldemort type, eg: <br></div><div>mixin("std.range.iota!(int, int).iota.Result a;"); //compile error</div><div><br></div><div>However, the compiler could help reduce it to something as simple as possible, eg:</div><div>"typeof(iota(int.init))"<br></div><div>here this would work:</div><div><div><br></div><div>mixin("typeof(iota(int.init)) a;"); //works<br></div></div><div><br></div><div>Is it possible to do that in a generic way, such that it hides as much as possible the details of the expression (here, "complex_expr_returning_3()" should be simplified to int.init)</div><div><br></div><div>Or is there another trick I could use to instantiate a variable with same type as a?</div><div><br></div><div><br></div><div>NOTE:</div><div><div>typeof(a) a2; </div><div>works even though <a href="http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591?pgno=2" target="_blank">http://www.drdobbs.com/cpp/voldemort-types-in-d/232901591?pgno=2</a> says it won't work, "Sorry, that won't work, the compiler will not allow a Voldemort Type to be instantiated outside of its scope " </div><div>(although that's doesn't help with my original problem)</div></div></div></div>