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
|
|
@ -1,56 +0,0 @@
|
|||
module;
|
||||
|
||||
#include <magic_enum_all.hpp>
|
||||
|
||||
export module magic_enum;
|
||||
|
||||
export namespace magic_enum {
|
||||
namespace customize {
|
||||
using customize::enum_range;
|
||||
}
|
||||
|
||||
namespace iostream_operators {
|
||||
using iostream_operators::operator<<;
|
||||
using iostream_operators::operator>>;
|
||||
}
|
||||
|
||||
namespace bitwise_operators {
|
||||
using bitwise_operators::operator~;
|
||||
using bitwise_operators::operator|;
|
||||
using bitwise_operators::operator&;
|
||||
using bitwise_operators::operator^;
|
||||
using bitwise_operators::operator|=;
|
||||
using bitwise_operators::operator&=;
|
||||
using bitwise_operators::operator^=;
|
||||
}
|
||||
|
||||
namespace containers {
|
||||
using containers::array;
|
||||
using containers::bitset;
|
||||
using containers::set;
|
||||
}
|
||||
|
||||
using magic_enum::enum_name;
|
||||
using magic_enum::enum_cast;
|
||||
using magic_enum::enum_value;
|
||||
using magic_enum::enum_values;
|
||||
using magic_enum::enum_count;
|
||||
using magic_enum::enum_integer;
|
||||
using magic_enum::enum_names;
|
||||
using magic_enum::enum_entries;
|
||||
using magic_enum::enum_fuse;
|
||||
using magic_enum::enum_switch;
|
||||
using magic_enum::enum_for_each;
|
||||
using magic_enum::enum_contains;
|
||||
using magic_enum::enum_index;
|
||||
using magic_enum::enum_flags_name;
|
||||
using magic_enum::enum_flags_contains;
|
||||
using magic_enum::enum_flags_cast;
|
||||
using magic_enum::enum_type_name;
|
||||
using magic_enum::is_unscoped_enum;
|
||||
using magic_enum::is_unscoped_enum_v;
|
||||
using magic_enum::is_scoped_enum;
|
||||
using magic_enum::is_scoped_enum_v;
|
||||
using magic_enum::underlying_type;
|
||||
using magic_enum::underlying_type_t;
|
||||
}
|
||||
|
|
@ -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 {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue