Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
GetTypeName
// Example program #include <iostream> #include <string> namespace internal { static const unsigned int FRONT_SIZE = 0; // sizeof("internal::GetTypeNameHelper<") - 1u; static const unsigned int BACK_SIZE = 0; //sizeof(">::GetTypeName") - 1u; template <typename T> struct GetTypeNameHelper { static const char* GetTypeName(void) { static const size_t size = sizeof(__PRETTY_FUNCTION__) - FRONT_SIZE - BACK_SIZE; static char typeName[size] = {}; memcpy(typeName, __PRETTY_FUNCTION__ + FRONT_SIZE, size - 1u); return typeName; } }; } template <typename T> const char* GetTypeName(void) { return internal::GetTypeNameHelper<T>::GetTypeName(); } struct Foo {}; class Bar {}; enum class eBaz : char { kOne }; int main() { std::cout << GetTypeName<int>() << std::endl; std::cout << GetTypeName<float>() << std::endl; std::cout << GetTypeName<Foo>() << std::endl; std::cout << GetTypeName<Bar>() << std::endl; std::cout << GetTypeName<eBaz>() << std::endl; }
run
|
edit
|
history
|
help
0
Ordered Graphs
MPL 2-0
Uno
Rounding float to nearest 1000 (fixed)
Apple is not convertible to itself (clang 3.8.0)
unordered graphs search
7
Own initialization
Error
std::reference_wrapper