Skip to content

Commit 903e756

Browse files
authored
support glaze 5.x (#26)
* support for glaze 5.x - glaze_v5_0_0_generic_supported * v0.8.12 * support glaze 5.x * rename namespace alias * update acording to review --------- Co-authored-by: Artur Bać <[email protected]>
1 parent 0372507 commit 903e756

File tree

2 files changed

+21
-13
lines changed

2 files changed

+21
-13
lines changed

ext_support/simple_enum/glaze_json_enum_name.hpp

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -85,10 +85,9 @@ namespace detail
8585
} // namespace detail
8686
} // namespace simple_enum::inline v0_8
8787

88-
namespace glz
89-
{
88+
9089
template<simple_enum::bounded_enum enumeration_type>
91-
struct meta<enumeration_type>
90+
struct glz::meta<enumeration_type>
9291
{
9392
static constexpr bool custom_write = true;
9493
static constexpr bool custom_read = true;
@@ -97,14 +96,15 @@ struct meta<enumeration_type>
9796
static constexpr auto value = simple_enum::detail::make_glaze_tuple<enumeration_type>();
9897
};
9998

100-
} // namespace glz
101-
102-
namespace glz::detail
103-
{
99+
#ifdef glaze_v5_0_0
100+
namespace glz_to_from_ns = glz;
101+
#else
102+
namespace glz_to_from_ns = glz::detail;
103+
#endif
104104

105105
template<simple_enum::bounded_enum enumeration_type>
106106
#ifdef glaze_v3_5_0_to_from
107-
struct from<glz::JSON, enumeration_type>
107+
struct glz_to_from_ns::from<glz::JSON, enumeration_type>
108108
#else
109109
struct from_json<enumeration_type>
110110
#endif
@@ -115,7 +115,11 @@ struct from_json<enumeration_type>
115115
{
116116
std::string_view value;
117117
#ifdef glaze_v3_5_0_to_from
118+
#ifdef glaze_v5_0_0_generic_supported
119+
parse<glz::JSON>::op<Opts>(value, ctx, args...);
120+
#else
118121
read<glz::JSON>::op<Opts>(value, ctx, args...);
122+
#endif
119123
#else
120124
read<glz::json>::op<Opts>(value, ctx, args...);
121125
#endif
@@ -136,7 +140,7 @@ struct from_json<enumeration_type>
136140

137141
template<simple_enum::bounded_enum enumeration_type>
138142
#ifdef glaze_v3_5_0_to_from
139-
struct to<glz::JSON, enumeration_type>
143+
struct glz_to_from_ns::to<glz::JSON, enumeration_type>
140144
#else
141145
struct to_json<enumeration_type>
142146
#endif
@@ -147,11 +151,14 @@ struct to_json<enumeration_type>
147151
{
148152
std::string_view value{simple_enum::enum_name(arg)};
149153
#ifdef glaze_v3_5_0_to_from
154+
#ifdef glaze_v5_0_0_generic_supported
155+
serialize<glz::JSON>::op<Opts>(value, args...);
156+
#else
150157
write<glz::JSON>::op<Opts>(value, args...);
158+
#endif
151159
#else
152160
write<glz::json>::op<Opts>(value, args...);
153161
#endif
154162
}
155163
};
156-
} // namespace glz::detail
157164

include/simple_enum/core.hpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,8 @@
66
#include <concepts>
77
#include <type_traits>
88

9-
#define SIMPLE_ENUM_NAME_VERSION "0.8.12"
9+
10+
#define SIMPLE_ENUM_NAME_VERSION "0.8.13"
1011

1112
namespace simple_enum::inline v0_8
1213
{
@@ -74,7 +75,7 @@ struct adl_info
7475
};
7576

7677
template<enum_concept enumeration>
77-
adl_info(enumeration const &, enumeration const &) -> adl_info<enumeration>;
78+
adl_info(enumeration const &) -> adl_info<enumeration>;
7879

7980
/**
8081
* @brief Function intended for ADL (Argument-Dependent Lookup) to provide custom enumeration bounds.
@@ -98,7 +99,7 @@ adl_info(enumeration const &, enumeration const &) -> adl_info<enumeration>;
9899
* with enumeration types that meet the `enum_concept` criteria:
99100
* @code
100101
* template<typename enumeration>
101-
* adl_info(enumeration const &, enumeration const &) -> adl_info<enumeration>;
102+
* adl_info(enumeration const &) -> adl_info<enumeration>;
102103
* @endcode
103104
*
104105
* @note Specializations of this function must ensure that first <= last.

0 commit comments

Comments
 (0)