mirror of
https://github.com/Neargye/magic_enum.git
synced 2026-01-09 23:34:23 +00:00
Add MAGIC_ENUM_USE_STD_MODULE option to use standard library module. (#350)
This commit is contained in:
parent
801c68bdc9
commit
db0b726c05
5 changed files with 32 additions and 0 deletions
|
|
@ -36,6 +36,7 @@
|
|||
#define MAGIC_ENUM_VERSION_MINOR 9
|
||||
#define MAGIC_ENUM_VERSION_PATCH 5
|
||||
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
#include <array>
|
||||
#include <cstddef>
|
||||
#include <cstdint>
|
||||
|
|
@ -43,11 +44,13 @@
|
|||
#include <limits>
|
||||
#include <type_traits>
|
||||
#include <utility>
|
||||
#endif
|
||||
|
||||
#if defined(MAGIC_ENUM_CONFIG_FILE)
|
||||
# include MAGIC_ENUM_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
#if !defined(MAGIC_ENUM_USING_ALIAS_OPTIONAL)
|
||||
# include <optional>
|
||||
#endif
|
||||
|
|
@ -57,6 +60,7 @@
|
|||
#if !defined(MAGIC_ENUM_USING_ALIAS_STRING_VIEW)
|
||||
# include <string_view>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#if defined(MAGIC_ENUM_NO_ASSERT)
|
||||
# define MAGIC_ENUM_ASSERT(...) static_cast<void>(0)
|
||||
|
|
|
|||
|
|
@ -36,10 +36,14 @@
|
|||
#include "magic_enum.hpp"
|
||||
|
||||
#if !defined(MAGIC_ENUM_NO_EXCEPTION) && (defined(__cpp_exceptions) || defined(__EXCEPTIONS) || defined(_CPPUNWIND))
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
# include <stdexcept>
|
||||
#endif
|
||||
# define MAGIC_ENUM_THROW(...) throw (__VA_ARGS__)
|
||||
#else
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
# include <cstdlib>
|
||||
#endif
|
||||
# define MAGIC_ENUM_THROW(...) std::abort()
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -50,7 +50,9 @@ namespace magic_enum::customize {
|
|||
|
||||
#if defined(__cpp_lib_format)
|
||||
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
#include <format>
|
||||
#endif
|
||||
|
||||
template <typename E>
|
||||
struct std::formatter<E, std::enable_if_t<std::is_enum_v<std::decay_t<E>> && magic_enum::customize::enum_format_enabled<E>(), char>> : std::formatter<std::string_view, char> {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,9 @@
|
|||
#include "magic_enum.hpp"
|
||||
#include "magic_enum_flags.hpp"
|
||||
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
#include <iosfwd>
|
||||
#endif
|
||||
|
||||
namespace magic_enum {
|
||||
|
||||
|
|
|
|||
|
|
@ -1,9 +1,23 @@
|
|||
module;
|
||||
|
||||
#include <version>
|
||||
#ifndef MAGIC_ENUM_USE_STD_MODULE
|
||||
#include <magic_enum_all.hpp>
|
||||
#endif
|
||||
|
||||
export module magic_enum;
|
||||
|
||||
#ifdef MAGIC_ENUM_USE_STD_MODULE
|
||||
import std;
|
||||
|
||||
extern "C++" {
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Winclude-angled-in-module-purview"
|
||||
#include <magic_enum_all.hpp>
|
||||
#pragma clang diagnostic pop
|
||||
}
|
||||
#endif
|
||||
|
||||
export namespace magic_enum {
|
||||
namespace customize {
|
||||
using customize::enum_range;
|
||||
|
|
@ -54,3 +68,9 @@ namespace containers {
|
|||
using magic_enum::underlying_type;
|
||||
using magic_enum::underlying_type_t;
|
||||
}
|
||||
|
||||
#if defined(__cpp_lib_format)
|
||||
export namespace std {
|
||||
using std::formatter;
|
||||
}
|
||||
#endif
|
||||
Loading…
Add table
Add a link
Reference in a new issue