How to get class name?

前端 未结 6 1352
萌比男神i
萌比男神i 2020-12-15 08:51

If I defined a class:

class Blah {};

How can I:

std::string const className = /* What do I need to do here? */;
assert( cla         


        
6条回答
  •  北海茫月
    2020-12-15 09:33

    Testing a class by looking at it's name sounds awfully like a Java style approach to me, and in C++, you should be wary of trying to apply the same patterns! A better way would be to use something like boost::type_traits, and may be is_same, with the real class name.

提交回复
热议问题