Skip to content

Commit bedcbe3

Browse files
Removed remaining references to enchantum
1 parent 2096a3b commit bedcbe3

3 files changed

Lines changed: 26 additions & 6 deletions

File tree

include/rfl/internal/enums/is_flag_enum.hpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,16 @@
22
#define RFL_INTERNAL_ENUMS_IS_FLAG_ENUM_HPP_
33

44
#include <concepts>
5+
#include <type_traits>
56

67
namespace rfl::internal::enums {
78

89
// Checks if an enum is a flag enum.
910
template <class EnumType>
10-
inline constexpr bool is_flag_enum = requires(EnumType e) {
11-
{ e | e } -> std::same_as<EnumType>;
12-
};
11+
inline constexpr bool is_flag_enum =
12+
std::is_enum_v<EnumType> && requires(EnumType e) {
13+
{ e | e } -> std::same_as<EnumType>;
14+
};
1315

1416
} // namespace rfl::internal::enums
1517

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#ifndef RFL_INTERNAL_ENUMS_IS_SCOPED_ENUM_HPP_
2+
#define RFL_INTERNAL_ENUMS_IS_SCOPED_ENUM_HPP_
3+
4+
#include <concepts>
5+
#include <type_traits>
6+
7+
namespace rfl::internal::enums {
8+
9+
// Checks if an enum is a flag enum.
10+
template <class EnumType>
11+
concept is_scoped_enum =
12+
std::is_enum_v<EnumType> &&
13+
(!std::is_convertible_v<EnumType, std::underlying_type_t<EnumType>>);
14+
15+
} // namespace rfl::internal::enums
16+
17+
#endif

include/rfl/parsing/ParserEnum.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@
77
#include "../Result.hpp"
88
#include "../config.hpp"
99
#include "../enums.hpp"
10-
#include "../internal/enums/cpp20/enchantum.hpp" // TODO: Replace this
10+
#include "../internal/enums/is_flag_enum.hpp"
11+
#include "../internal/enums/is_scoped_enum.hpp"
1112
#include "../internal/has_reflector.hpp"
1213
#include "../internal/underlying_enums_v.hpp"
1314
#include "AreReaderAndWriter.hpp"
@@ -52,7 +53,7 @@ struct ParserEnum {
5253

5354
} else if constexpr (internal::underlying_enums_v<ProcessorsType> ||
5455
schemaful::IsSchemafulReader<R>) {
55-
static_assert(enchantum::ScopedEnum<T>,
56+
static_assert(internal::enums::is_scoped_enum<T>,
5657
"The enum must be a scoped enum in order to retrieve "
5758
"the underlying value.");
5859
return _r.template to_basic_type<std::underlying_type_t<T>>(_var)
@@ -111,7 +112,7 @@ struct ParserEnum {
111112
if constexpr (internal::underlying_enums_v<ProcessorsType> ||
112113
schemaful::IsSchemafulReader<R>) {
113114
return Type{Type::Integer{}};
114-
} else if constexpr (enchantum::is_bitflag<U>) {
115+
} else if constexpr (internal::enums::is_flag_enum<U>) {
115116
return Type{Type::String{}};
116117
} else if constexpr (config::enum_descriptions<U>::has_descriptions) {
117118
// Generate DescribedLiteral for enums with descriptions

0 commit comments

Comments
 (0)