45 namespace json_details {
46 template<
template<
typename...>
typename Trait,
typename... Params>
48 using type = Trait<Params...>;
52 static_cast<bool>( std::declval<T>( ) ) );
56 template<
typename Constructor,
typename... Args>
57 struct constructor_cannot_be_invoked;
59 template<
typename Constructor,
typename... Args>
60 struct construction_result
62 daw::is_callable_v<Constructor, Args...>,
63 std::invoke_result<Constructor, Args...>,
64 daw::traits::identity<
65 constructor_cannot_be_invoked<Constructor, Args...>>> {};
68 namespace json_details {
69 template<
typename JsonMember>
70 using without_name =
typename JsonMember::without_name;
72 template<
typename JsonMember, JSONNAMETYPE NewName,
bool Cond>
73 using copy_name_when = daw::conditional_t<
74 Cond,
typename JsonMember::template with_name<NewName>, JsonMember>;
76 template<
typename JsonMember, JSONNAMETYPE NewName>
77 using copy_name_when_noname =
78 copy_name_when<JsonMember, NewName, is_no_name_v<JsonMember>>;
81 namespace json_details {
89 force_aggregate_construction_test1,
93 T::force_aggregate_construction );
105 json_details::force_aggregate_construction_test1<T> or
106 json_details::force_aggregate_construction_test2<T>;
108 namespace json_details {
109 template<
typename,
typename =
void>
110 struct json_constructor;
113 struct json_constructor<T,
std::void_t<typename T::constructor_t>> {
114 using type =
typename T::constructor_t;
118 using json_constructor_t =
typename json_constructor<T>::type;
120 template<
typename,
typename =
void>
124 struct json_result<T,
std::void_t<typename T::parse_to_t>> {
125 using type =
typename T::parse_to_t;
129 using json_result_t =
typename json_result<T>::type;
131 template<
typename,
typename =
void>
132 struct json_base_type;
135 struct json_base_type<T,
std::void_t<json_result_t<T>>> {
136 using type = json_result_t<T>;
140 using json_base_type_t =
typename json_base_type<T>::type;
143 is_default_default_constructor_type_v,
144 T::i_am_the_default_default_constructor_type );
147 T::has_stateless_allocator );
153 inline constexpr bool must_be_class_member_v =
false;
156 template<
typename Constructor,
typename T,
typename ParseState>
158 not json_details::has_data_contract_constructor_v<T> and
159 ( force_aggregate_construction_v<T> or
160 json_details::is_default_default_constructor_type_v<Constructor> or
161 not json_details::has_stateless_allocator_v<ParseState> );
163 template<
typename... Ts>
175 template<
typename Char,
typename CharTrait,
typename Allocator>
177 std::basic_string<Char, CharTrait, Allocator>> =
true;
181 std::bool_constant<can_single_allocation_string_v<T>>;
183 namespace json_details {
185 T::i_am_a_json_type );
187 template<
typename... Ts>
188 inline constexpr bool are_json_types_v = ( is_a_json_type_v<Ts> and ... );
193 T::i_am_an_ordered_member );
196 using is_an_ordered_member =
197 std::bool_constant<is_an_ordered_member_v<T>>;
200 T::i_am_a_json_tagged_variant );
203 using json_class_constructor_t_impl =
207 using data_contract_constructor_t =
210 template<
typename T,
typename Default>
211 using json_class_constructor_t = daw::detected_or_t<
212 typename daw::conditional_t<
213 std::is_same_v<use_default, Default>,
214 daw::conditional_t<has_data_contract_constructor_v<T>,
215 ident_trait<data_contract_constructor_t, T>,
216 ident_trait<default_constructor, T>>,
217 daw::traits::identity<Default>>::type,
218 json_class_constructor_t_impl, T>;
221 is_string_view_like_v, ( (
void)( std::data( std::declval<T>( ) ) ),
222 (
void)( std::size( std::declval<T>( ) ) ) ) );
224 static_assert( is_string_view_like_v<std::string_view> );
235 template<
typename CharT,
typename Traits,
typename Alloc>
236 inline constexpr bool
237 is_zero_terminated_string_v<std::basic_string<CharT, Traits, Alloc>> =
242 std::bool_constant<is_zero_terminated_string_v<T>>;
244 namespace json_details {
245 template<
typename ParsePolicy, auto Option>
246 using apply_policy_option_t =
247 typename ParsePolicy::template SetPolicyOptions<Option>;
249 template<
typename ParsePolicy,
typename String, auto Option>
250 using apply_zstring_policy_option_t = daw::conditional_t<
251 is_zero_terminated_string_v<daw::remove_cvref_t<String>>,
252 apply_policy_option_t<ParsePolicy, Option>, ParsePolicy>;
254 template<
typename String>
255 inline constexpr bool is_mutable_string_v =
256 not std::is_const_v<std::remove_pointer_t<std::remove_reference_t<
257 decltype( std::data( std::declval<String &&>( ) ) )>>>;
292 namespace json_details {
293 template<
typename T,
typename ParseState>
294 DAW_CPP20_CONCEPT all_json_members_must_exist_v =
295 not ignore_unknown_members_v<T> and
296 ( is_exact_class_mapping_v<T> or
297 ParseState::use_exact_mappings_by_default );
301 template<
template<
typename...>
typename T,
typename... Params>
302 struct identity_parts {
303 using type = T<Params...>;
314 std::is_pointer_v<T> or json_details::has_element_type<T>;
318 template<
typename Tuple,
typename =
void>
321 template<
typename... Ts>
323 using type = std::tuple<Ts...>;
325 static constexpr auto size =
sizeof...( Ts );
327 template<std::
size_t Idx>
330 template<std::
size_t Idx,
typename Tuple>
331 static constexpr decltype( auto )
get( Tuple &&tp ) {
332 return std::get<Idx>( DAW_FWD( tp ) );
336 template<
typename... Ts>
338 using type = daw::fwd_pack<Ts...>;
340 static constexpr auto size =
sizeof...( Ts );
342 template<std::
size_t Idx>
344 daw::remove_cvref_t<typename std::tuple_element_t<Idx, type>>;
346 template<std::
size_t Idx,
typename Tuple>
347 static constexpr decltype( auto )
get( Tuple &&tp ) {
348 return DAW_FWD( tp ).template get<Idx>( );
359 (std::is_copy_constructible_v<T> and std::is_copy_assignable_v<T>) or
360 ( std::is_move_constructible_v<T> and std::is_move_assignable_v<T> ) );
362 namespace json_details {
363 template<
typename,
typename =
void>
364 inline constexpr bool is_tuple_v =
false;
366 template<
typename... Ts>
367 inline constexpr bool is_tuple_v<std::tuple<Ts...>> =
true;
370 inline constexpr bool
371 is_tuple_v<T, typename tuple_elements_pack<T>::type> =
true;
374 using unwrapped_t = concepts::nullable_value_type_t<T>;
377 using mapped_type_t =
typename T::mapped_type;
380 using key_type_t =
typename T::key_type;
383#if true or defined( DAW_JSON_DISABLE_RANDOM )
385 DAW_CPP20_CONCEPT can_be_random_iterator_v =
false;
387 template<
bool IsKnown>
388 DAW_CPP20_CONCEPT can_be_random_iterator_v = IsKnown;
394 template<
typename JsonMember>
395 using literal_json_type_as_string =
typename JsonMember::as_string;
398 T::i_am_a_deduced_empty_class );
401 struct ensure_mapped {
402 static_assert( is_a_json_type_v<T>,
403 "The supplied type does not have a json_data_contract" );
408 using ensure_mapped_t =
typename ensure_mapped<T>::type;
410 DAW_MAKE_REQ_TRAIT_TYPE( is_json_member_list_v,
411 T::i_am_a_json_member_list );
414 using ordered_member_subtype_test =
typename T::json_member;
417 using ordered_member_subtype_t =
418 typename daw::detected_or_t<T, ordered_member_subtype_test, T>;
420 template<
typename T,
typename Default>
421 inline constexpr auto json_class_constructor =
422 json_class_constructor_t<T, Default>{ };
425 using json_nullable_member_type_t =
typename T::member_type;