1818#include < utility>
1919#include < vector>
2020
21- #define DAW_REFL ( ... ) ^^__VA_ARGS__
21+ // This gets around clang-format issues
22+ #define DAW_REFLECT ( ... ) ^^__VA_ARGS__
23+ #define DAW_SPLICE ( ... ) [:__VA_ARGS__:]
2224#define DAW_SPLICE ( ... ) [:__VA_ARGS__:]
2325
2426namespace daw ::json::inline DAW_JSON_VER {
@@ -60,7 +62,8 @@ namespace daw::json::inline DAW_JSON_VER {
6062 // / Get the public non-static data members
6163 consteval std::vector<std::meta::info>
6264 pub_nsdm_of ( std::meta::info type_class ) {
63- auto members = std::meta::nonstatic_data_members_of ( type_class );
65+ auto members = std::meta::nonstatic_data_members_of (
66+ type_class, std::meta::access_context::unprivileged ( ) );
6467 std::erase_if ( members, []( std::meta::info const &i ) {
6568 return not std::meta::is_public ( i );
6669 } );
@@ -71,15 +74,15 @@ namespace daw::json::inline DAW_JSON_VER {
7174 consteval auto expand ( R range ) {
7275 auto args = std::vector<std::meta::info>( );
7376 for ( auto r : range ) {
74- args.push_back ( std::meta::reflect_value ( r ) );
77+ args.push_back ( std::meta::reflect_constant ( r ) );
7578 }
76- return std::meta::substitute ( DAW_REFL ( replicator ), args );
79+ return std::meta::substitute ( DAW_REFLECT ( replicator ), args );
7780 }
7881
7982 template <typename T>
8083 consteval std::optional<T> get_annotaion ( std::meta::info r ) {
8184 for ( std::meta::info a : std::meta::annotations_of ( r ) ) {
82- if ( std::meta::type_of ( a ) == DAW_REFL ( T ) ) {
85+ if ( std::meta::type_of ( a ) == DAW_REFLECT ( T ) ) {
8386 return std::meta::extract<T>( a );
8487 }
8588 }
@@ -88,9 +91,9 @@ namespace daw::json::inline DAW_JSON_VER {
8891
8992 template <typename T>
9093 consteval bool has_annotation ( std::meta::info r, T const &value ) {
91- auto expected = std::meta::reflect_value ( value );
94+ auto expected = std::meta::reflect_constant ( value );
9295 for ( std::meta::info a : std::meta::annotations_of ( r ) ) {
93- if ( value_of ( a ) == expected ) {
96+ if ( constant_of ( a ) == expected ) {
9497 return true ;
9598 }
9699 }
@@ -99,20 +102,20 @@ namespace daw::json::inline DAW_JSON_VER {
99102
100103 template <typename T, std::size_t ... Is>
101104 consteval auto to_tuple ( T const &value, std::index_sequence<Is...> )
102- -> decltype( std::tuple(
103- value.DAW_SPLICE( pub_nsdm_of( DAW_REFL ( T ) )[Is] )... ) ) {
104- return std::tuple (
105- value.DAW_SPLICE ( pub_nsdm_of ( DAW_REFL ( T ) )[Is] )... ) ;
105+ -> decltype( std::tuple{
106+ value.DAW_SPLICE ( pub_nsdm_of ( DAW_REFLECT ( T ) )[Is] )... } ) {
107+ return std::tuple{
108+ value.DAW_SPLICE ( pub_nsdm_of ( DAW_REFLECT ( T ) )[Is] )... } ;
106109 }
107110
108111 template <typename T>
109- consteval auto
110- to_tuple ( T const &value ) -> decltype ( refl_details::to_tuple(
111- value,
112- std::make_index_sequence< pub_nsdm_of( DAW_REFL ( T ) ).size( )>{ } ) ) {
112+ consteval auto to_tuple ( T const &value )
113+ -> decltype( refl_details::to_tuple(
114+ value, std::make_index_sequence<
115+ pub_nsdm_of ( DAW_REFLECT ( T ) ).size( )>{ } ) ) {
113116 return refl_details::to_tuple (
114- value,
115- std::make_index_sequence< pub_nsdm_of ( DAW_REFL ( T ) ).size ( )>{ } );
117+ value, std::make_index_sequence<
118+ pub_nsdm_of ( DAW_REFLECT ( T ) ).size ( )>{ } );
116119 }
117120
118121 template <JSONNAMETYPE Name, typename T>
@@ -126,7 +129,8 @@ namespace daw::json::inline DAW_JSON_VER {
126129
127130 template <typename T, std::size_t Idx>
128131 consteval auto get_member_link_func ( ) {
129- static constexpr auto member_info = pub_nsdm_of ( DAW_REFL ( T ) )[Idx];
132+ static constexpr auto member_info =
133+ pub_nsdm_of ( DAW_REFLECT ( T ) )[Idx];
130134 static constexpr auto annot_rename =
131135 get_annotaion<daw::json::refl_rename>( member_info );
132136
@@ -147,14 +151,14 @@ namespace daw::json::inline DAW_JSON_VER {
147151 return refl_map_as_annot;
148152 } else if constexpr ( refl_enum_string_annot ) {
149153 using json_member_no_name =
150- daw::json::enum_string<DAW_SPLICE (
154+ daw::json::enum_string<typename DAW_SPLICE (
151155 std::meta::type_of ( member_info ) ),
152156 refl_enum_string_annot->Options >;
153157 static constexpr auto info =
154- DAW_REFL ( typename json_member_no_name::template with_name<
155- json_name<name.size ( ) + 1 >(
156- name.data ( ),
157- std::make_index_sequence<name.size ( ) + 1 >{ } )> );
158+ DAW_REFLECT ( typename json_member_no_name::template with_name<
159+ json_name<name.size ( ) + 1 >(
160+ name.data ( ),
161+ std::make_index_sequence<name.size ( ) + 1 >{ } )> );
158162 return std::optional<refl_map_as>{ refl_map_as{ info } };
159163 } else {
160164 return false ;
@@ -166,7 +170,7 @@ namespace daw::json::inline DAW_JSON_VER {
166170 not annot_rename,
167171 " Do not use reflect.rename and reflect.map_as at the same time" );
168172 static constexpr auto result =
169- daw::traits::identity<DAW_SPLICE ( annot_map_as->type )>{ };
173+ daw::traits::identity<typename DAW_SPLICE ( annot_map_as->type )>{ };
170174 return result;
171175 } else {
172176 return daw::traits::identity<deduce_t <
@@ -206,15 +210,15 @@ namespace daw::json::inline DAW_JSON_VER {
206210
207211 DAW_ATTRIB_INLINE static constexpr auto to_json_data ( T const &value ) {
208212 return daw::forward_nonrvalue_as_tuple (
209- value.DAW_SPLICE ( pub_nsdm_of ( DAW_REFL ( T ) )[Is] )... );
213+ value.DAW_SPLICE ( pub_nsdm_of ( DAW_REFLECT ( T ) )[Is] )... );
210214 }
211215 };
212216
213217 template <typename E>
214218 requires std::is_enum_v<E> constexpr E
215219 enum_from_string ( std::string_view name ) {
216220 template for ( constexpr auto enumerator :
217- std::meta::enumerators_of ( DAW_REFL ( E ) ) ) {
221+ std::meta::enumerators_of ( DAW_REFLECT ( E ) ) ) {
218222 if ( name == std::meta::identifier_of ( enumerator ) ) {
219223 return DAW_SPLICE ( enumerator );
220224 }
@@ -227,7 +231,7 @@ namespace daw::json::inline DAW_JSON_VER {
227231 requires std::is_enum_v<E>
228232 constexpr std::string_view enum_to_string( E value ) {
229233 template for( constexpr auto enumerator: std::meta::enumerators_of(
230- DAW_REFL ( E ) ) ) { if( value == DAW_SPLICE( enumerator ) ) { return
234+ DAW_REFLECT ( E ) ) ) { if( value == DAW_SPLICE( enumerator ) ) { return
231235 std::meta::identifier_of( enumerator );
232236 }
233237 }
@@ -238,7 +242,7 @@ namespace daw::json::inline DAW_JSON_VER {
238242 requires std::is_enum_v<E> constexpr std::string_view
239243 enum_to_string ( E value ) {
240244 auto result = std::string_view{ };
241- DAW_SPLICE ( expand ( std::meta::enumerators_of ( DAW_REFL ( E ) ) ) ) >>
245+ DAW_SPLICE ( expand ( std::meta::enumerators_of ( DAW_REFLECT ( E ) ) ) ) >>
242246 [&]<auto e> {
243247 if ( value == DAW_SPLICE ( e ) ) {
244248 result = std::meta::identifier_of ( e );
@@ -271,7 +275,9 @@ namespace daw::json::inline DAW_JSON_VER {
271275 }
272276
273277 template <typename JsonMember>
274- static constexpr auto map_as = refl_map_as{ DAW_REFL ( JsonMember ) };
278+ static consteval auto map_as ( ) {
279+ return refl_map_as{ DAW_REFLECT ( JsonMember ) };
280+ }
275281
276282 static constexpr auto ignore_with_default =
277283 daw::json::refl_ignore_with_default{ };
@@ -292,17 +298,16 @@ namespace daw::json::inline DAW_JSON_VER {
292298 // Trait that specifies a type is to be reflected on for parse info
293299 template <refl_details::Reflectable T>
294300 inline constexpr bool is_reflectible_type_v =
295- refl_details::has_annotation ( DAW_REFL ( T ), reflect );
301+ refl_details::has_annotation ( DAW_REFLECT ( T ), reflect );
296302 } // namespace experimental
297303
298304 template <typename T>
299305 requires is_reflectible_type_v<T> //
300306 struct json_data_contract <T>
301307 : refl_details::make_data_contract<
302308 T, std::make_index_sequence<
303- refl_details::pub_nsdm_of ( DAW_REFL ( T ) ).size( )>> {};
309+ refl_details::pub_nsdm_of ( DAW_REFLECT ( T ) ).size( )>> {};
304310
305311} // namespace daw::json::inline DAW_JSON_VER
306312
307- #undef DAW_REFL
308313#undef DAW_SPLICE
0 commit comments