8 #include <nlohmann/detail/iterators/iterator_traits.hpp>
9 #include <nlohmann/detail/macro_scope.hpp>
10 #include <nlohmann/detail/meta/cpp_future.hpp>
11 #include <nlohmann/detail/meta/detected.hpp>
12 #include <nlohmann/json_fwd.hpp>
41 NLOHMANN_BASIC_JSON_TPL_DECLARATION
49 using mapped_type_t =
typename T::mapped_type;
52 using key_type_t =
typename T::key_type;
55 using value_type_t =
typename T::value_type;
58 using difference_type_t =
typename T::difference_type;
61 using pointer_t =
typename T::pointer;
64 using reference_t =
typename T::reference;
67 using iterator_category_t =
typename T::iterator_category;
70 using iterator_t =
typename T::iterator;
72 template <
typename T,
typename... Args>
73 using to_json_function = decltype(T::to_json(std::declval<Args>()...));
75 template <
typename T,
typename... Args>
76 using from_json_function = decltype(T::from_json(std::declval<Args>()...));
78 template <
typename T,
typename U>
79 using get_template_function = decltype(std::declval<T>().
template get<U>());
82 template <
typename BasicJsonType,
typename T,
typename =
void>
85 template <
typename BasicJsonType,
typename T>
89 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
91 static constexpr
bool value =
92 is_detected_exact<void, from_json_function, serializer,
93 const BasicJsonType&, T&>::value;
98 template <
typename BasicJsonType,
typename T,
typename =
void>
101 template<
typename BasicJsonType,
typename T>
104 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
106 static constexpr
bool value =
107 is_detected_exact<T, from_json_function, serializer,
108 const BasicJsonType&>::value;
113 template <
typename BasicJsonType,
typename T,
typename =
void>
116 template <
typename BasicJsonType,
typename T>
119 using serializer =
typename BasicJsonType::template json_serializer<T, void>;
121 static constexpr
bool value =
122 is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
131 template <
typename T,
typename =
void>
134 template <
typename T>
141 static constexpr
auto value =
142 is_detected<value_type_t, traits>::value &&
143 is_detected<difference_type_t, traits>::value &&
144 is_detected<pointer_t, traits>::value &&
145 is_detected<iterator_category_t, traits>::value &&
146 is_detected<reference_t, traits>::value;
151 template <
typename T,
typename =
void>
154 template <
typename T>
157 template <
typename BasicJsonType,
typename CompatibleObjectType,
161 template <
typename BasicJsonType,
typename CompatibleObjectType>
163 BasicJsonType, CompatibleObjectType,
164 enable_if_t<is_detected<mapped_type_t, CompatibleObjectType>::value and
165 is_detected<key_type_t, CompatibleObjectType>::value >>
168 using object_t =
typename BasicJsonType::object_t;
171 static constexpr
bool value =
172 std::is_constructible<
typename object_t::key_type,
173 typename CompatibleObjectType::key_type>::value and
174 std::is_constructible<
typename object_t::mapped_type,
175 typename CompatibleObjectType::mapped_type>::value;
178 template <
typename BasicJsonType,
typename CompatibleObjectType>
182 template <
typename BasicJsonType,
typename ConstructibleObjectType,
186 template <
typename BasicJsonType,
typename ConstructibleObjectType>
188 BasicJsonType, ConstructibleObjectType,
189 enable_if_t<is_detected<mapped_type_t, ConstructibleObjectType>::value and
190 is_detected<key_type_t, ConstructibleObjectType>::value >>
192 using object_t =
typename BasicJsonType::object_t;
194 static constexpr
bool value =
195 (std::is_default_constructible<ConstructibleObjectType>::value and
196 (std::is_move_assignable<ConstructibleObjectType>::value or
197 std::is_copy_assignable<ConstructibleObjectType>::value) and
198 (std::is_constructible<
typename ConstructibleObjectType::key_type,
199 typename object_t::key_type>::value and
201 typename object_t::mapped_type,
202 typename ConstructibleObjectType::mapped_type >::value)) or
204 typename ConstructibleObjectType::mapped_type>::value or
207 typename ConstructibleObjectType::mapped_type >::value);
210 template <
typename BasicJsonType,
typename ConstructibleObjectType>
213 ConstructibleObjectType> {};
215 template <
typename BasicJsonType,
typename CompatibleStringType,
219 template <
typename BasicJsonType,
typename CompatibleStringType>
221 BasicJsonType, CompatibleStringType,
222 enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
223 value_type_t, CompatibleStringType>::value >>
225 static constexpr
auto value =
226 std::is_constructible<typename BasicJsonType::string_t, CompatibleStringType>::value;
229 template <
typename BasicJsonType,
typename ConstructibleStringType>
233 template <
typename BasicJsonType,
typename ConstructibleStringType,
237 template <
typename BasicJsonType,
typename ConstructibleStringType>
239 BasicJsonType, ConstructibleStringType,
240 enable_if_t<is_detected_exact<typename BasicJsonType::string_t::value_type,
241 value_type_t, ConstructibleStringType>::value >>
243 static constexpr
auto value =
244 std::is_constructible<ConstructibleStringType,
245 typename BasicJsonType::string_t>::value;
248 template <
typename BasicJsonType,
typename ConstructibleStringType>
252 template <
typename BasicJsonType,
typename CompatibleArrayType,
typename =
void>
255 template <
typename BasicJsonType,
typename CompatibleArrayType>
257 BasicJsonType, CompatibleArrayType,
258 enable_if_t<is_detected<value_type_t, CompatibleArrayType>::value and
259 is_detected<iterator_t, CompatibleArrayType>::value and
264 iterator_traits<CompatibleArrayType>>::value >>
266 static constexpr
bool value =
267 std::is_constructible<BasicJsonType,
268 typename CompatibleArrayType::value_type>::value;
271 template <
typename BasicJsonType,
typename CompatibleArrayType>
275 template <
typename BasicJsonType,
typename ConstructibleArrayType,
typename =
void>
278 template <
typename BasicJsonType,
typename ConstructibleArrayType>
280 BasicJsonType, ConstructibleArrayType,
281 enable_if_t<std::is_same<ConstructibleArrayType,
282 typename BasicJsonType::value_type>::value >>
285 template <
typename BasicJsonType,
typename ConstructibleArrayType>
287 BasicJsonType, ConstructibleArrayType,
288 enable_if_t<not std::is_same<ConstructibleArrayType,
289 typename BasicJsonType::value_type>::value and
290 std::is_default_constructible<ConstructibleArrayType>::value and
291 (std::is_move_assignable<ConstructibleArrayType>::value or
292 std::is_copy_assignable<ConstructibleArrayType>::value) and
293 is_detected<value_type_t, ConstructibleArrayType>::value and
294 is_detected<iterator_t, ConstructibleArrayType>::value and
296 detected_t<value_type_t, ConstructibleArrayType>>::value >>
298 static constexpr
bool value =
306 (std::is_same<
typename ConstructibleArrayType::value_type,
307 typename BasicJsonType::array_t::value_type>::value or
309 typename ConstructibleArrayType::value_type>::value or
311 BasicJsonType,
typename ConstructibleArrayType::value_type >::value);
314 template <
typename BasicJsonType,
typename ConstructibleArrayType>
318 template <
typename RealIntegerType,
typename CompatibleNumberIntegerType,
322 template <
typename RealIntegerType,
typename CompatibleNumberIntegerType>
324 RealIntegerType, CompatibleNumberIntegerType,
325 enable_if_t<std::is_integral<RealIntegerType>::value and
326 std::is_integral<CompatibleNumberIntegerType>::value and
327 not std::is_same<bool, CompatibleNumberIntegerType>::value >>
330 using RealLimits = std::numeric_limits<RealIntegerType>;
331 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
333 static constexpr
auto value =
334 std::is_constructible<RealIntegerType,
335 CompatibleNumberIntegerType>::value and
336 CompatibleLimits::is_integer and
337 RealLimits::is_signed == CompatibleLimits::is_signed;
340 template <
typename RealIntegerType,
typename CompatibleNumberIntegerType>
343 CompatibleNumberIntegerType> {};
345 template <
typename BasicJsonType,
typename CompatibleType,
typename =
void>
348 template <
typename BasicJsonType,
typename CompatibleType>
350 BasicJsonType, CompatibleType,
353 static constexpr
bool value =
357 template <
typename BasicJsonType,
typename CompatibleType>
364 template<
class B1,
class... Bn>
366 : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
368 template <
typename T1,
typename T2>
371 template <
typename T1,
typename... Args>
namespace for Niels Lohmann
Definition: adl_serializer.hpp:9
Definition: type_traits.hpp:363
Definition: type_traits.hpp:362
Definition: type_traits.hpp:83
Definition: type_traits.hpp:99
Definition: type_traits.hpp:114
Definition: type_traits.hpp:39
Definition: type_traits.hpp:253
Definition: type_traits.hpp:273
Definition: type_traits.hpp:320
Definition: type_traits.hpp:343
Definition: type_traits.hpp:159
Definition: type_traits.hpp:180
Definition: type_traits.hpp:217
Definition: type_traits.hpp:231
Definition: type_traits.hpp:346
Definition: type_traits.hpp:359
Definition: type_traits.hpp:152
Definition: type_traits.hpp:276
Definition: type_traits.hpp:316
Definition: type_traits.hpp:184
Definition: type_traits.hpp:213
Definition: type_traits.hpp:235
Definition: type_traits.hpp:250
Definition: type_traits.hpp:369
Definition: type_traits.hpp:132
Definition: iterator_traits.hpp:32