digitalmars.D.learn - Displaying type of something
- Georg Wrede (4/4) Mar 09 2009 When creating templates, it is sometimes handy to print the type of
- Lars Kyllingstad (3/9) Mar 09 2009 typeof(t).stringof
- bearophile (5/7) Mar 09 2009 writeln("Typeof T is: ", typeid(typeof(t)));
- Georg Wrede (11/18) Mar 09 2009 Thanks!!!
- Christopher Wright (3/9) Mar 09 2009 For a class or interface:
- Georg Wrede (10/20) Mar 09 2009 A a;
When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it? writeln("Typeof T is: ", typeof(t)); This doesn't work, but you get the idea.
Mar 09 2009
Georg Wrede wrote:When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it? writeln("Typeof T is: ", typeof(t)); This doesn't work, but you get the idea.typeof(t).stringof -Lars
Mar 09 2009
Georg Wrede:When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it?writeln("Typeof T is: ", typeid(typeof(t))); (Try alternatives of that with a dynamic type, like a class). Bye, bearophile
Mar 09 2009
bearophile wrote:Georg Wrede:Thanks!!! class A { } class B : A { } class C : B { } A a; B b; C c; A ac = new C; Typeof ac is: A So it's the variable, not its current contents. Kinda makes sense.When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it?writeln("Typeof T is: ", typeid(typeof(t))); (Try alternatives of that with a dynamic type, like a class).
Mar 09 2009
Georg Wrede wrote:When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it? writeln("Typeof T is: ", typeof(t)); This doesn't work, but you get the idea.For a class or interface: writeln("Typeof T is: ", t.classinfo.name);
Mar 09 2009
Christopher Wright wrote:Georg Wrede wrote:A a; B b; C c; A ac = new C; writeln("Typeof T is: ", ac.classinfo.name); and the result is: Typeof T is: C so it really works!!! Thaks, guys!!When creating templates, it is sometimes handy to print the type of something. Is there a trivial way to print it? writeln("Typeof T is: ", typeof(t)); This doesn't work, but you get the idea.For a class or interface: writeln("Typeof T is: ", t.classinfo.name);
Mar 09 2009