fix doc and naming
This commit is contained in:
parent
1baf418d21
commit
a6b2aac0b5
3 changed files with 19 additions and 19 deletions
|
@ -4,7 +4,7 @@
|
|||
|
||||
# Nameof Type
|
||||
|
||||
* To check is nameof_type supported compiler use macro `NAMEOF_TYPE_SUPPORTED` or constexpr constant `nameof::is_nameof_type_supported`.
|
||||
* To check is nameof type supported compiler use macro `NAMEOF_TYPE_SUPPORTED` or constexpr constant `nameof::is_nameof_type_supported`.
|
||||
|
||||
* This library uses a compiler-specific hack (based on `__PRETTY_FUNCTION__` / `__FUNCSIG__`), which works on Clang >= 5, MSVC >= 15.3 and GCC >= 7.
|
||||
|
||||
|
@ -14,28 +14,28 @@
|
|||
|
||||
# Nameof Enum
|
||||
|
||||
* To check is nameof_enum supported compiler use macro `NAMEOF_ENUM_SUPPORTED` or constexpr constant `nameof::is_nameof_enum_supported`.
|
||||
* To check is nameof enum supported compiler use macro `NAMEOF_ENUM_SUPPORTED` or constexpr constant `nameof::is_nameof_enum_supported`.
|
||||
|
||||
* This library uses a compiler-specific hack (based on `__PRETTY_FUNCTION__` / `__FUNCSIG__`), which works on Clang >= 5, MSVC >= 15.3 and GCC >= 9.
|
||||
|
||||
* Enum can't reflect if the enum is a forward declaration.
|
||||
|
||||
* Enum value must be in range `[MAGIC_ENUM_RANGE_MIN, MAGIC_ENUM_RANGE_MAX]`. By default `MAGIC_ENUM_RANGE_MIN = -128`, `MAGIC_ENUM_RANGE_MAX = 128`.
|
||||
* Enum value must be in range `[NAMEOF_ENUM_RANGE_MIN, NAMEOF_ENUM_RANGE_MAX]`. By default `NAMEOF_ENUM_RANGE_MIN = -128`, `NAMEOF_ENUM_RANGE_MAX = 128`.
|
||||
|
||||
* If need another range for all enum types by default, redefine the macro `MAGIC_ENUM_RANGE_MIN` and `MAGIC_ENUM_RANGE_MAX`.
|
||||
* If need another range for all enum types by default, redefine the macro `NAMEOF_ENUM_RANGE_MIN` and `NAMEOF_ENUM_RANGE_MAX`.
|
||||
```cpp
|
||||
#define MAGIC_ENUM_RANGE_MIN 0
|
||||
#define MAGIC_ENUM_RANGE_MAX 256
|
||||
#include <magic_enum.hpp>
|
||||
#define NAMEOF_ENUM_RANGE_MIN 0
|
||||
#define NAMEOF_ENUM_RANGE_MAX 256
|
||||
#include <nameof.hpp>
|
||||
```
|
||||
|
||||
* If need another range for specific enum type, add specialization `enum_range` for necessary enum type.
|
||||
```cpp
|
||||
#include <magic_enum.hpp>
|
||||
#include <nameof.hpp>
|
||||
|
||||
enum number { one = 100, two = 200, three = 300 };
|
||||
|
||||
namespace magic_enum {
|
||||
namespace nameof {
|
||||
template <>
|
||||
struct enum_range<number> {
|
||||
static constexpr int min = 100;
|
||||
|
@ -44,7 +44,7 @@
|
|||
}
|
||||
```
|
||||
|
||||
* `magic_enum` obtains the first defined value enums, and won't work if value are aliased.
|
||||
* Nameof enum obtains the first defined value enums, and won't work if value are aliased.
|
||||
```cpp
|
||||
enum ShapeKind {
|
||||
ConvexBegin = 0,
|
||||
|
@ -55,8 +55,8 @@
|
|||
Banana = 3,
|
||||
COUNT = 4,
|
||||
};
|
||||
// magic_enum::enum_cast<ShapeKind>("Box") -> std::nullopt
|
||||
// magic_enum::enum_name(ShapeKind::Box) -> "ConvexBegin"
|
||||
// nameof::nameof_enum(ShapeKind::Box) -> "ConvexBegin"
|
||||
// NAMEOF_ENUM(ShapeKind::Box) -> "ConvexBegin"
|
||||
```
|
||||
Work around the issue:
|
||||
```cpp
|
||||
|
@ -75,10 +75,10 @@
|
|||
ConvexBegin = Box,
|
||||
ConvexEnd = Sphere + 1,
|
||||
};
|
||||
// magic_enum::enum_cast<ShapeKind>("Box") -> ShapeKind::Box
|
||||
// magic_enum::enum_name(ShapeKind::Box) -> "Box"
|
||||
// nameof::nameof_enum(ShapeKind::Box) -> "Box"
|
||||
// NAMEOF_ENUM(ShapeKind::Box) -> "Box"
|
||||
|
||||
// Non-reflected aliases.
|
||||
// magic_enum::enum_cast<ShapeKind>("ConvexBegin") -> std::nullopt
|
||||
// magic_enum::enum_name(ShapeKind::ConvexBegin) -> "Box"
|
||||
// nameof::nameof_enum(ShapeKind::ConvexBegin) -> "Box"
|
||||
// NAMEOF_ENUM(ShapeKind::ConvexBegin) -> "Box"
|
||||
```
|
||||
|
|
|
@ -14,7 +14,7 @@
|
|||
* [`NAMEOF_TYPE_EXPR` macro that obtains string name type of expression, reference and cv-qualifiers are ignored.](#NAMEOF_TYPE_EXPR)
|
||||
* [`NAMEOF_FULL_TYPE_EXPR` macro that obtains string name full type of expression, with reference and cv-qualifiers.](#NAMEOF_FULL_TYPE_EXPR)
|
||||
|
||||
## Synopsis
|
||||
# Synopsis
|
||||
|
||||
* Before use, read the [limitations](limitations.md) of functionality.
|
||||
|
||||
|
|
|
@ -381,7 +381,7 @@ constexpr std::size_t reflected_size() {
|
|||
static_assert(reflected_max_v<E> > reflected_min_v<E>, "nameof::enum_range requires max > min.");
|
||||
constexpr auto size = reflected_max_v<E> - reflected_min_v<E> + 1;
|
||||
static_assert(size > 0, "nameof::enum_range requires valid size.");
|
||||
static_assert(size < (std::numeric_limits<std::int16_t>::max)(), "magic_enum::enum_range requires valid size.");
|
||||
static_assert(size < (std::numeric_limits<std::int16_t>::max)(), "nameof::enum_range requires valid size.");
|
||||
|
||||
return static_cast<std::size_t>(size);
|
||||
}
|
||||
|
@ -415,7 +415,7 @@ constexpr std::size_t range_size() noexcept {
|
|||
static_assert(is_enum_v<E>, "nameof::detail::range_size requires enum type.");
|
||||
constexpr auto size = max_v<E> - min_v<E> + 1;
|
||||
static_assert(size > 0, "nameof::enum_range requires valid size.");
|
||||
static_assert(size < (std::numeric_limits<std::int16_t>::max)(), "magic_enum::enum_range requires valid size.");
|
||||
static_assert(size < (std::numeric_limits<std::int16_t>::max)(), "nameof::enum_range requires valid size.");
|
||||
|
||||
return static_cast<std::size_t>(size);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue