Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions include/magic_enum/magic_enum.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,18 +36,21 @@
#define MAGIC_ENUM_VERSION_MINOR 9
#define MAGIC_ENUM_VERSION_PATCH 5

#ifndef MAGIC_ENUM_USE_STD_MODULE
#include <array>
#include <cstddef>
#include <cstdint>
#include <functional>
#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
Expand All @@ -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)
Expand Down
4 changes: 4 additions & 0 deletions include/magic_enum/magic_enum_containers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 2 additions & 0 deletions include/magic_enum/magic_enum_format.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> {
Expand Down
2 changes: 2 additions & 0 deletions include/magic_enum/magic_enum_iostream.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 {

Expand Down
20 changes: 20 additions & 0 deletions include/magic_enum/magic_enum.cppm → module/magic_enum.cppm
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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