diff --git a/CMakeLists.txt b/CMakeLists.txt index 2ae1bda..caac5f5 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) diff --git a/README.md b/README.md index 8604f28..e6b3493 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ [![Build Status](https://travis-ci.org/Neargye/magic_enum.svg?branch=master)](https://travis-ci.org/Neargye/magic_enum) [![Build status](https://ci.appveyor.com/api/projects/status/0rpr966p9ssrvwu3/branch/master?svg=true)](https://ci.appveyor.com/project/Neargye/magic-enum-hf8vk/branch/master) [![Codacy Badge](https://api.codacy.com/project/badge/Grade/64d04f150af14c3e8bd1090057b68538)](https://www.codacy.com/app/Neargye/magic_enum?utm_source=github.com&utm_medium=referral&utm_content=Neargye/magic_enum&utm_campaign=Badge_Grade) -[![Try online](https://img.shields.io/badge/try-online-blue.svg)](https://wandbox.org/permlink/vvYmXey2yclPdeKM) +[![Try online](https://img.shields.io/badge/try-online-blue.svg)](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(); +constexpr auto color_name = magic_enum::enum_to_string(); 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 +``` + ## Integration You have to add required file [magic_enum.hpp](include/magic_enum.hpp). diff --git a/include/magic_enum.hpp b/include/magic_enum.hpp index 0bfd4ef..cb9ce4a 100644 --- a/include/magic_enum.hpp +++ b/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 . // SPDX-License-Identifier: MIT @@ -37,6 +37,7 @@ #include #include +// 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 diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index a1c8bd5..8bfcde3 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -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)