http://d.puremagic.com/issues/show_bug.cgi?id=8762
Summary: instanceOf trait for static conditionals Product: D Version: unspecified Platform: All OS/Version: All Status: NEW Severity: enhancement Priority: P2 Component: Phobos AssignedTo: nob...@puremagic.com ReportedBy: monarchdo...@gmail.com --- Comment #0 from monarchdo...@gmail.com 2012-10-05 02:23:10 PDT --- As discussed here: http://forum.dlang.org/thread/ssqgyxzggmzugbfbb...@forum.dlang.org The idea would be a trait "instanceOf!T" that returns a reference to a T. The advantage of this approach is that it allows "extracting" an instance out of T, without ever worrying about how or where said instance came from. This is particularly important because some types don't have T.init, and immutables don't have T t = void. The intersection of both these groups is {0} ... Example: //---- template isAssignable(T, U) { enum bool isAssignable = is(typeof(instanceOf!T = instanceOf!U)); } //---- The "signature" (as improved on by Simen Kjaeraas) would be: //---- @property ref T instanceOf( T )( ); //---- But remain un-implemented. This would ensure it is not actually usable during run-time. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------