Is there a standard way in c++11 to get the name of a class either with some template black magic or dynamically with some standard library function?
相关问题
- Sorting 3 numbers without branching [closed]
- How to compile C++ code in GDB?
- Why does const allow implicit conversion of refere
- thread_local variables initialization
- What uses more memory in c++? An 2 ints or 2 funct
相关文章
- Class layout in C++: Why are members sometimes ord
- How to mock methods return object with deleted cop
- Which is the best way to multiply a large and spar
- C++ default constructor does not initialize pointe
- Selecting only the first few characters in a strin
- What exactly do pointers store? (C++)
- Converting glm::lookat matrix to quaternion and ba
- What is the correct way to declare and use a FILE
Once I found the pretty printing of the function prototype quite useful:
In GCC, PRETTY_FUNCTION contains the type signature of the function as well as its bare name.
For example for a templated class or function you get the class names expanded as a C-string:
This would give you something like
If you had instantiated the class with, e.g. doubles. But it gives you also user defined types.
Not very fancy, but it has its uses.
No, but you could make one:
and then either add the static member
class_name
to the class:or specialize meta:
(here's a macro to make that easier)
and then use the meta template:
If you really want to get crafty, you can make a version for functions too, but these would (obviously) have to be specialized.