Last active
August 18, 2021 09:37
-
-
Save talybin/e4a94aa9c94b09dd766b4510c8cf7c69 to your computer and use it in GitHub Desktop.
Type name revisited. This generates only actual type of name in output binary.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#pragma once | |
#include <utility> | |
template <class T, std::size_t... I> | |
inline const char* type_name(std::index_sequence<I...>) { | |
static constexpr char name[] = { __PRETTY_FUNCTION__[I + 60]..., 0 }; | |
return name; | |
} | |
template <class T> | |
inline const char* type_name() { | |
return type_name<T>( | |
std::make_index_sequence<sizeof(__PRETTY_FUNCTION__) - 36>()); | |
} | |
template <class T> | |
inline const char* type_name(const T&) { | |
return type_name<T>(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Note! Offsets need to be adjusted if signature changes.