|
5 | 5 | // | |\ | (_| | | | | | | __/ (_) | | | |____|_| |_|
|
6 | 6 | // |_| \_|\__,_|_| |_| |_|\___|\___/|_| \_____|
|
7 | 7 | // https://github.com/Neargye/nameof
|
8 |
| -// version 0.9.5 |
| 8 | +// version 0.10.0 |
9 | 9 | //
|
10 | 10 | // Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
11 | 11 | // SPDX-License-Identifier: MIT
|
|
33 | 33 | #define NEARGYE_NAMEOF_HPP
|
34 | 34 |
|
35 | 35 | #define NAMEOF_VERSION_MAJOR 0
|
36 |
| -#define NAMEOF_VERSION_MINOR 9 |
37 |
| -#define NAMEOF_VERSION_PATCH 5 |
| 36 | +#define NAMEOF_VERSION_MINOR 10 |
| 37 | +#define NAMEOF_VERSION_PATCH 0 |
38 | 38 |
|
39 | 39 | #include <array>
|
40 | 40 | #include <cassert>
|
@@ -326,7 +326,7 @@ std::basic_ostream<Char, Traits>& operator<<(std::basic_ostream<Char, Traits>& o
|
326 | 326 |
|
327 | 327 | namespace detail {
|
328 | 328 |
|
329 |
| -constexpr string_view pretty_name(string_view name, bool remove_template_suffix = true) noexcept { |
| 329 | +constexpr string_view pretty_name(string_view name, bool remove_suffix = true) noexcept { |
330 | 330 | if (name.size() >= 1 && (name[0] == '"' || name[0] == '\'')) {
|
331 | 331 | return {}; // Narrow multibyte string literal.
|
332 | 332 | } else if (name.size() >= 2 && name[0] == 'R' && (name[1] == '"' || name[1] == '\'')) {
|
@@ -392,7 +392,7 @@ constexpr string_view pretty_name(string_view name, bool remove_template_suffix
|
392 | 392 | break;
|
393 | 393 | }
|
394 | 394 | }
|
395 |
| - if (remove_template_suffix) { |
| 395 | + if (remove_suffix) { |
396 | 396 | name.remove_suffix(s);
|
397 | 397 | }
|
398 | 398 |
|
@@ -567,9 +567,17 @@ constexpr auto values(std::index_sequence<I...>) noexcept {
|
567 | 567 | template <typename E, bool IsFlags, typename U = std::underlying_type_t<E>>
|
568 | 568 | constexpr auto values() noexcept {
|
569 | 569 | static_assert(is_enum_v<E>, "nameof::detail::values requires enum type.");
|
570 |
| - constexpr auto range_size = reflected_max_v<E, IsFlags> - reflected_min_v<E, IsFlags> + 1; |
| 570 | + constexpr auto min = reflected_min_v<E, IsFlags>; |
| 571 | + constexpr auto max = reflected_max_v<E, IsFlags>; |
| 572 | + constexpr auto range_size = max - min + 1; |
571 | 573 | static_assert(range_size > 0, "nameof::enum_range requires valid size.");
|
572 | 574 | static_assert(range_size < (std::numeric_limits<std::uint16_t>::max)(), "nameof::enum_range requires valid size.");
|
| 575 | + if constexpr (cmp_less((std::numeric_limits<U>::min)(), min) && !IsFlags) { |
| 576 | + static_assert(!is_valid<E, value<E, min - 1, IsFlags>(0)>(), "nameof::enum_range detects enum value smaller than min range size."); |
| 577 | + } |
| 578 | + if constexpr (cmp_less(range_size, (std::numeric_limits<U>::max)()) && !IsFlags) { |
| 579 | + static_assert(!is_valid<E, value<E, min, IsFlags>(range_size + 1)>(), "nameof::enum_range detects enum value larger than max range size."); |
| 580 | + } |
573 | 581 |
|
574 | 582 | return values<E, IsFlags, reflected_min_v<E, IsFlags>>(std::make_index_sequence<range_size>{});
|
575 | 583 | }
|
@@ -987,7 +995,7 @@ template <typename T>
|
987 | 995 | #define NAMEOF_SHORT_TYPE_EXPR(...) ::nameof::nameof_short_type<decltype(__VA_ARGS__)>()
|
988 | 996 |
|
989 | 997 | // Obtains type name, with reference and cv-qualifiers, using RTTI.
|
990 |
| -#define NAMEOF_TYPE_RTTI(...) ::nameof::detail::nameof_type_rtti<decltype(__VA_ARGS__)>(typeid(__VA_ARGS__).name()) |
| 998 | +#define NAMEOF_TYPE_RTTI(...) ::nameof::detail::nameof_type_rtti<::std::void_t<decltype(__VA_ARGS__)>>(typeid(__VA_ARGS__).name()) |
991 | 999 |
|
992 | 1000 | // Obtains full type name, using RTTI.
|
993 | 1001 | #define NAMEOF_FULL_TYPE_RTTI(...) ::nameof::detail::nameof_full_type_rtti<decltype(__VA_ARGS__)>(typeid(__VA_ARGS__).name())
|
|
0 commit comments