Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.50 KB | None | 0 0
  1. #include <boost/type_index.hpp>
  2. #include <iostream>
  3.  
  4. #define DEFINE_NAME \
  5. std::string name \
  6. { \
  7. boost::typeindex::type_id<decltype(*this)>().pretty_name() \
  8. };
  9.  
  10. class Test2
  11. {
  12. public:
  13. DEFINE_NAME
  14. };
  15.  
  16. int main()
  17. {
  18. Test2 t;
  19. std::clog << t.name << std::endl; // human readable
  20. return 0;
  21. }
  22. //output :
  23. // Test2
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement