using nodiscard only where it's need

This commit is contained in:
neargye 2019-09-13 19:45:01 +05:00
parent 9de7bbaeb8
commit 48ffc2f855

View file

@ -214,7 +214,7 @@ template <typename T>
} }
template <typename E, E V> template <typename E, E V>
[[nodiscard]] constexpr auto n() noexcept { constexpr auto n() noexcept {
static_assert(std::is_enum_v<E>, "nameof::detail::nameof_enum requires enum type."); static_assert(std::is_enum_v<E>, "nameof::detail::nameof_enum requires enum type.");
#if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 9 #if defined(__clang__) || defined(__GNUC__) && __GNUC__ >= 9
constexpr auto name = nameof({__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 2}); constexpr auto name = nameof({__PRETTY_FUNCTION__, sizeof(__PRETTY_FUNCTION__) - 2});
@ -234,14 +234,14 @@ template <typename E, E V>
inline constexpr auto nameof_enum_v = n<E, V>(); inline constexpr auto nameof_enum_v = n<E, V>();
template <typename E, int O, int... I> template <typename E, int O, int... I>
[[nodiscard]] constexpr auto enum_names(std::integer_sequence<int, I...>) noexcept { constexpr auto enum_names(std::integer_sequence<int, I...>) noexcept {
static_assert(std::is_enum_v<E>, "nameof::detail::enum_names requires enum type."); static_assert(std::is_enum_v<E>, "nameof::detail::enum_names requires enum type.");
return std::array<std::string_view, sizeof...(I)>{{nameof_enum_v<E, static_cast<E>(I + O)>...}}; return std::array<std::string_view, sizeof...(I)>{{nameof_enum_v<E, static_cast<E>(I + O)>...}};
} }
template <typename... T> template <typename... T>
[[nodiscard]] constexpr auto n() noexcept { constexpr auto n() noexcept {
#if defined(__clang__) #if defined(__clang__)
constexpr std::string_view name{__PRETTY_FUNCTION__ + 31, sizeof(__PRETTY_FUNCTION__) - 34}; constexpr std::string_view name{__PRETTY_FUNCTION__ + 31, sizeof(__PRETTY_FUNCTION__) - 34};
#elif defined(__GNUC__) #elif defined(__GNUC__)