44 namespace json_details {
45 template<
template<
typename...>
typename Trait,
typename... Params>
47 using type = Trait<Params...>;
51 static_cast<bool>( std::declval<T>( ) ) );
55 template<
typename Constructor,
typename... Args>
56 struct constructor_cannot_be_invoked;
58 template<
typename Constructor,
typename... Args>
59 struct construction_result
61 daw::is_callable_v<Constructor, Args...>,
62 std::invoke_result<Constructor, Args...>,
63 daw::traits::identity<
64 constructor_cannot_be_invoked<Constructor, Args...>>> {};
67 namespace json_details {
68 template<
typename JsonMember>
69 using without_name =
typename JsonMember::without_name;
71 template<
typename JsonMember, JSONNAMETYPE NewName,
bool Cond>
72 using copy_name_when = daw::conditional_t<
73 Cond,
typename JsonMember::template with_name<NewName>, JsonMember>;
75 template<
typename JsonMember, JSONNAMETYPE NewName>
76 using copy_name_when_noname =
77 copy_name_when<JsonMember, NewName, is_no_name_v<JsonMember>>;
80 namespace json_details {
88 force_aggregate_construction_test1,
92 T::force_aggregate_construction );
104 json_details::force_aggregate_construction_test1<T> or
105 json_details::force_aggregate_construction_test2<T>;
107 namespace json_details {
108 template<
typename,
typename =
void>
109 struct json_constructor;
112 struct json_constructor<T,
std::void_t<typename T::constructor_t>> {
113 using type =
typename T::constructor_t;
117 using json_constructor_t =
typename json_constructor<T>::type;
119 template<
typename,
typename =
void>
123 struct json_result<T,
std::void_t<typename T::parse_to_t>> {
124 using type =
typename T::parse_to_t;
128 using json_result_t =
typename json_result<T>::type;
130 template<
typename,
typename =
void>
131 struct json_base_type;
134 struct json_base_type<T,
std::void_t<json_result_t<T>>> {
135 using type = json_result_t<T>;
139 using json_base_type_t =
typename json_base_type<T>::type;
142 is_default_default_constructor_type_v,
143 T::i_am_the_default_default_constructor_type );
146 T::has_stateless_allocator );
152 inline constexpr bool must_be_class_member_v =
false;
155 template<
typename Constructor,
typename T,
typename ParseState>
157 not json_details::has_data_contract_constructor_v<T> and
158 ( force_aggregate_construction_v<T> or
159 json_details::is_default_default_constructor_type_v<Constructor> or
160 not json_details::has_stateless_allocator_v<ParseState> );
162 template<
typename... Ts>
174 template<
typename Char,
typename CharTrait,
typename Allocator>
176 std::basic_string<Char, CharTrait, Allocator>> =
true;
180 std::bool_constant<can_single_allocation_string_v<T>>;
182 namespace json_details {
184 T::i_am_a_json_type );
186 template<
typename... Ts>
187 inline constexpr bool are_json_types_v = ( is_a_json_type_v<Ts> and ... );
192 T::i_am_an_ordered_member );
195 using is_an_ordered_member =
196 std::bool_constant<is_an_ordered_member_v<T>>;
199 T::i_am_a_json_tagged_variant );
202 using json_class_constructor_t_impl =
206 using data_contract_constructor_t =
209 template<
typename T,
typename Default>
210 using json_class_constructor_t = daw::detected_or_t<
211 typename daw::conditional_t<
212 std::is_same_v<use_default, Default>,
213 daw::conditional_t<has_data_contract_constructor_v<T>,
214 ident_trait<data_contract_constructor_t, T>,
215 ident_trait<default_constructor, T>>,
216 daw::traits::identity<Default>>::type,
217 json_class_constructor_t_impl, T>;
220 is_string_view_like_v, ( (
void)( std::data( std::declval<T>( ) ) ),
221 (
void)( std::size( std::declval<T>( ) ) ) ) );
223 static_assert( is_string_view_like_v<std::string_view> );
234 template<
typename CharT,
typename Traits,
typename Alloc>
235 inline constexpr bool
236 is_zero_terminated_string_v<std::basic_string<CharT, Traits, Alloc>> =
241 std::bool_constant<is_zero_terminated_string_v<T>>;
243 namespace json_details {
244 template<
typename ParsePolicy, auto Option>
245 using apply_policy_option_t =
246 typename ParsePolicy::template SetPolicyOptions<Option>;
248 template<
typename ParsePolicy,
typename String, auto Option>
249 using apply_zstring_policy_option_t = daw::conditional_t<
250 is_zero_terminated_string_v<daw::remove_cvref_t<String>>,
251 apply_policy_option_t<ParsePolicy, Option>, ParsePolicy>;
253 template<
typename String>
254 inline constexpr bool is_mutable_string_v =
255 not std::is_const_v<std::remove_pointer_t<std::remove_reference_t<
256 decltype( std::data( std::declval<String &&>( ) ) )>>>;
291 namespace json_details {
292 template<
typename T,
typename ParseState>
293 DAW_CPP20_CONCEPT all_json_members_must_exist_v =
294 not ignore_unknown_members_v<T> and
295 ( is_exact_class_mapping_v<T> or
296 ParseState::use_exact_mappings_by_default );
300 template<
template<
typename...>
typename T,
typename... Params>
301 struct identity_parts {
302 using type = T<Params...>;
313 std::is_pointer_v<T> or json_details::has_element_type<T>;
317 template<
typename Tuple,
typename =
void>
320 template<
typename... Ts>
322 using type = std::tuple<Ts...>;
324 static constexpr auto size =
sizeof...( Ts );
326 template<std::
size_t Idx>
329 template<std::
size_t Idx,
typename Tuple>
330 static constexpr decltype( auto )
get( Tuple &&tp ) {
331 return std::get<Idx>( DAW_FWD( tp ) );
335 template<
typename... Ts>
337 using type = daw::fwd_pack<Ts...>;
339 static constexpr auto size =
sizeof...( Ts );
341 template<std::
size_t Idx>
343 daw::remove_cvref_t<typename std::tuple_element_t<Idx, type>>;
345 template<std::
size_t Idx,
typename Tuple>
346 static constexpr decltype( auto )
get( Tuple &&tp ) {
347 return DAW_FWD( tp ).template get<Idx>( );
358 (std::is_copy_constructible_v<T> and std::is_copy_assignable_v<T>) or
359 ( std::is_move_constructible_v<T> and std::is_move_assignable_v<T> ) );
361 namespace json_details {
362 template<
typename,
typename =
void>
363 inline constexpr bool is_tuple_v =
false;
365 template<
typename... Ts>
366 inline constexpr bool is_tuple_v<std::tuple<Ts...>> =
true;
369 inline constexpr bool
370 is_tuple_v<T, typename tuple_elements_pack<T>::type> =
true;
373 using unwrapped_t = concepts::nullable_value_type_t<T>;
376 using mapped_type_t =
typename T::mapped_type;
379 using key_type_t =
typename T::key_type;
382#if true or defined( DAW_JSON_DISABLE_RANDOM )
384 DAW_CPP20_CONCEPT can_be_random_iterator_v =
false;
386 template<
bool IsKnown>
387 DAW_CPP20_CONCEPT can_be_random_iterator_v = IsKnown;
393 template<
typename JsonMember>
394 using literal_json_type_as_string =
typename JsonMember::as_string;
397 T::i_am_a_deduced_empty_class );