
2012/5/30 Nevin Liber <nevin@eviloverlord.com>:
On 29 May 2012 14:29, Antony Polukhin <antoshkka@gmail.com> wrote:
Would be there some interest in function for getting class name without RTTI?
To be clear, this does not do the same thing as RTTI. For instance:
struct B { virtual ~B() {} }; struct D : B {}; // ... D d; B& b(d); std::cout << template_type(b) << std::endl;
will print B, not D.
Yeep, you`ve got it!
That being said, this is mighty useful, especially when doing non-trivial things with templates.
Now, I'd rather the interface return some kind of range, as there are many times I don't want to pay the allocation cost for putting it in a string.
I was implementing const char* raw_name() and std::string name_demangled(). First returns zero terminated character sequence that contains not very nice names: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > >::name_begin(void) or std::basic_string<char>] Second returns more user friendly nice printable name: class std::basic_string<char,struct std::char_traits<char>,class std::allocator<char> > or std::basic_string<char> Any more feature requests? -- Best regards, Antony Polukhin