msvc binsize improve

on clang all already ok
This commit is contained in:
neargye 2019-11-14 20:41:51 +05:00
parent 534ece4154
commit 33023e3275

View file

@ -552,7 +552,6 @@ constexpr auto n() noexcept {
# elif defined(_MSC_VER) # elif defined(_MSC_VER)
constexpr std::string_view name{__FUNCSIG__ + 63, sizeof(__FUNCSIG__) - 81 - (__FUNCSIG__[sizeof(__FUNCSIG__) - 19] == ' ' ? 1 : 0)}; constexpr std::string_view name{__FUNCSIG__ + 63, sizeof(__FUNCSIG__) - 81 - (__FUNCSIG__[sizeof(__FUNCSIG__) - 19] == ' ' ? 1 : 0)};
# endif # endif
static_assert(name.size() > 0, "Type does not have a name.");
return cstring<name.size()>{name}; return cstring<name.size()>{name};
#else #else
@ -591,20 +590,26 @@ template <auto V>
template <typename T> template <typename T>
[[nodiscard]] constexpr auto nameof_type() noexcept { [[nodiscard]] constexpr auto nameof_type() noexcept {
#if defined(_MSC_VER) #if defined(_MSC_VER)
return detail::n<detail::identity<detail::remove_cvref_t<T>>>(); constexpr auto name = detail::n<detail::identity<detail::remove_cvref_t<T>>>();
#else #else
return detail::n<detail::remove_cvref_t<T>>(); constexpr auto name = detail::n<detail::remove_cvref_t<T>>();
#endif #endif
static_assert(name.size() > 0, "Type does not have a name.");
return name;
} }
// Obtains string name of full type, with reference and cv-qualifiers. // Obtains string name of full type, with reference and cv-qualifiers.
template <typename T> template <typename T>
[[nodiscard]] constexpr auto nameof_full_type() noexcept { [[nodiscard]] constexpr auto nameof_full_type() noexcept {
#if defined(_MSC_VER) #if defined(_MSC_VER)
return detail::n<detail::identity<T>>(); constexpr auto name = detail::n<detail::identity<T>>();
#else #else
return detail::n<T>(); constexpr auto name = detail::n<T>();
#endif #endif
static_assert(name.size() > 0, "Type does not have a name.");
return name;
} }
} // namespace nameof } // namespace nameof
@ -615,7 +620,8 @@ template <typename T>
constexpr auto name = ::nameof::detail::pretty_name(#__VA_ARGS__, true); \ constexpr auto name = ::nameof::detail::pretty_name(#__VA_ARGS__, true); \
static_assert(name.size() > 0, "Expression does not have a name."); \ static_assert(name.size() > 0, "Expression does not have a name."); \
constexpr auto size = name.size(); \ constexpr auto size = name.size(); \
return ::nameof::cstring<size>{name}; }() constexpr auto nameof = ::nameof::cstring<size>{name}; \
return nameof; }()
// Obtains simple (unqualified) full (with template suffix) string name of variable, function, macro. // Obtains simple (unqualified) full (with template suffix) string name of variable, function, macro.
#define NAMEOF_FULL(...) []() constexpr noexcept { \ #define NAMEOF_FULL(...) []() constexpr noexcept { \
@ -623,7 +629,8 @@ template <typename T>
constexpr auto name = ::nameof::detail::pretty_name(#__VA_ARGS__, false); \ constexpr auto name = ::nameof::detail::pretty_name(#__VA_ARGS__, false); \
static_assert(name.size() > 0, "Expression does not have a name."); \ static_assert(name.size() > 0, "Expression does not have a name."); \
constexpr auto size = name.size(); \ constexpr auto size = name.size(); \
return ::nameof::cstring<size>{name}; }() constexpr auto nameof_full = ::nameof::cstring<size>{name}; \
return nameof_full; }()
// Obtains raw string name of variable, function, macro. // Obtains raw string name of variable, function, macro.
#define NAMEOF_RAW(...) []() constexpr noexcept { \ #define NAMEOF_RAW(...) []() constexpr noexcept { \
@ -631,7 +638,8 @@ template <typename T>
constexpr auto name = ::std::string_view{#__VA_ARGS__}; \ constexpr auto name = ::std::string_view{#__VA_ARGS__}; \
static_assert(name.size() > 0, "Expression does not have a name."); \ static_assert(name.size() > 0, "Expression does not have a name."); \
constexpr auto size = name.size(); \ constexpr auto size = name.size(); \
return ::nameof::cstring<size>{name}; }() constexpr auto nameof_raw = ::nameof::cstring<size>{name}; \
return nameof_raw; }()
// Obtains simple (unqualified) string enum name of enum variable. // Obtains simple (unqualified) string enum name of enum variable.
#define NAMEOF_ENUM(...) ::nameof::nameof_enum(__VA_ARGS__) #define NAMEOF_ENUM(...) ::nameof::nameof_enum(__VA_ARGS__)