mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
v0.1.1
This commit is contained in:
parent
f2c3bd8fe5
commit
c74e53aabe
4 changed files with 14 additions and 6 deletions
|
|
@ -1,6 +1,6 @@
|
|||
cmake_minimum_required(VERSION 3.6)
|
||||
|
||||
project(magic_enum VERSION "0.1.0" LANGUAGES CXX)
|
||||
project(magic_enum VERSION "0.1.1" LANGUAGES CXX)
|
||||
|
||||
option(MAGIC_ENUM_OPT_BUILD_EXAMPLES "Build magic_enum examples" ON)
|
||||
option(MAGIC_ENUM_OPT_BUILD_TESTS "Build and perform magic_enum tests" ON)
|
||||
|
|
|
|||
14
README.md
14
README.md
|
|
@ -16,7 +16,7 @@
|
|||
[](https://travis-ci.org/Neargye/magic_enum)
|
||||
[](https://ci.appveyor.com/project/Neargye/magic-enum-hf8vk/branch/master)
|
||||
[](https://www.codacy.com/app/Neargye/magic_enum?utm_source=github.com&utm_medium=referral&utm_content=Neargye/magic_enum&utm_campaign=Badge_Grade)
|
||||
[](https://wandbox.org/permlink/vvYmXey2yclPdeKM)
|
||||
[](https://wandbox.org/permlink/gkjJ86ur57I3KOO6)
|
||||
|
||||
## What is Magic Enum?
|
||||
|
||||
|
|
@ -44,9 +44,9 @@ if (color_name.has_value()) {
|
|||
// color_name.value() -> "RED"
|
||||
}
|
||||
|
||||
constexpr auto cx_color = Color::BLUE;
|
||||
constexpr auto color = Color::BLUE;
|
||||
// Static storage enum variable to string enum name.
|
||||
constexpr auto color_name = magic_enum::enum_to_string<cx_color>();
|
||||
constexpr auto color_name = magic_enum::enum_to_string<color>();
|
||||
if (color_name.has_value()) {
|
||||
// color_name.value() -> "BLUE"
|
||||
}
|
||||
|
|
@ -61,6 +61,14 @@ if (color.has_value()) {
|
|||
}
|
||||
```
|
||||
|
||||
## Remarks
|
||||
|
||||
* Enum variable must be in range (-MAGIC_ENUM_RANGE, MAGIC_ENUM_RANGE). By default MAGIC_ENUM_RANGE = 128. If you need a larger range, redefine the macro MAGIC_ENUM_RANGE.
|
||||
```cpp
|
||||
#define MAGIC_ENUM_RANGE 1028 // Redefine MAGIC_ENUM_RANGE for larger range.
|
||||
#include <magic_enum.hpp>
|
||||
```
|
||||
|
||||
## Integration
|
||||
|
||||
You have to add required file [magic_enum.hpp](include/magic_enum.hpp).
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
// | | | | (_| | (_| | | (__ | |____| | | | |_| | | | | | | | |____|_| |_|
|
||||
// |_| |_|\__,_|\__, |_|\___| |______|_| |_|\__,_|_| |_| |_| \_____|
|
||||
// __/ | https://github.com/Neargye/magic_enum
|
||||
// |___/ vesion 0.1.0
|
||||
// |___/ vesion 0.1.1
|
||||
//
|
||||
// Licensed under the MIT License <http://opensource.org/licenses/MIT>.
|
||||
// SPDX-License-Identifier: MIT
|
||||
|
|
@ -37,6 +37,7 @@
|
|||
#include <string_view>
|
||||
#include <optional>
|
||||
|
||||
// Enum variable must be in range (-MAGIC_ENUM_RANGE, MAGIC_ENUM_RANGE). If you need a larger range, redefine the macro MAGIC_ENUM_RANGE.
|
||||
#if !defined(MAGIC_ENUM_RANGE)
|
||||
# define MAGIC_ENUM_RANGE 128
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ if(CMAKE_CXX_COMPILER_ID MATCHES "MSVC")
|
|||
if(HAS_PERMISSIVE_FLAG)
|
||||
set(OPTIONS ${OPTIONS} /permissive-)
|
||||
endif()
|
||||
set(OPTIONS ${OPTIONS} /wd4702) # Disable warning C4702: unreachable code
|
||||
|
||||
set(HAS_CPP11_FLAG TRUE)
|
||||
check_cxx_compiler_flag(/std:c++14 HAS_CPP14_FLAG)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue