WPILibC++ 2024.1.1-beta-4
type_traits.h
Go to the documentation of this file.
1// __ _____ _____ _____
2// __| | __| | | | JSON for Modern C++
3// | | |__ | | | | | | version 3.11.2
4// |_____|_____|_____|_|___| https://github.com/nlohmann/json
5//
6// SPDX-FileCopyrightText: 2013-2022 Niels Lohmann <https://nlohmann.me>
7// SPDX-License-Identifier: MIT
8
9#pragma once
10
11#include <limits> // numeric_limits
12#include <type_traits> // false_type, is_constructible, is_integral, is_same, true_type
13#include <utility> // declval
14#include <tuple> // tuple
15
22#include <wpi/json_fwd.h>
23
25/*!
26@brief detail namespace with internal helper functions
27
28This namespace collects functions that should not be exposed,
29implementations of some @ref basic_json methods, and meta-programming helpers.
30
31@since version 2.1.0
32*/
33namespace detail
34{
35
36/////////////
37// helpers //
38/////////////
39
40// Note to maintainers:
41//
42// Every trait in this file expects a non CV-qualified type.
43// The only exceptions are in the 'aliases for detected' section
44// (i.e. those of the form: decltype(T::member_function(std::declval<T>())))
45//
46// In this case, T has to be properly CV-qualified to constraint the function arguments
47// (e.g. to_json(BasicJsonType&, const T&))
48
49template<typename> struct is_basic_json : std::false_type {};
50
52struct is_basic_json<WPI_BASIC_JSON_TPL> : std::true_type {};
53
54// used by exceptions create() member functions
55// true_type for pointer to possibly cv-qualified basic_json or std::nullptr_t
56// false_type otherwise
57template<typename BasicJsonContext>
59 std::integral_constant < bool,
60 is_basic_json<typename std::remove_cv<typename std::remove_pointer<BasicJsonContext>::type>::type>::value
61 || std::is_same<BasicJsonContext, std::nullptr_t>::value >
62{};
63
64//////////////////////
65// json_ref helpers //
66//////////////////////
67
68template<typename>
69class json_ref;
70
71template<typename>
72struct is_json_ref : std::false_type {};
73
74template<typename T>
75struct is_json_ref<json_ref<T>> : std::true_type {};
76
77//////////////////////////
78// aliases for detected //
79//////////////////////////
80
81template<typename T>
82using mapped_type_t = typename T::mapped_type;
83
84template<typename T>
85using key_type_t = typename T::key_type;
86
87template<typename T>
88using value_type_t = typename T::value_type;
89
90template<typename T>
91using difference_type_t = typename T::difference_type;
92
93template<typename T>
94using pointer_t = typename T::pointer;
95
96template<typename T>
97using reference_t = typename T::reference;
98
99template<typename T>
100using iterator_category_t = typename T::iterator_category;
101
102template<typename T, typename... Args>
103using to_json_function = decltype(T::to_json(std::declval<Args>()...));
104
105template<typename T, typename... Args>
106using from_json_function = decltype(T::from_json(std::declval<Args>()...));
107
108template<typename T, typename U>
109using get_template_function = decltype(std::declval<T>().template get<U>());
110
111// trait checking if JSONSerializer<T>::from_json(json const&, udt&) exists
112template<typename BasicJsonType, typename T, typename = void>
113struct has_from_json : std::false_type {};
114
115// trait checking if j.get<T> is valid
116// use this trait instead of std::is_constructible or std::is_convertible,
117// both rely on, or make use of implicit conversions, and thus fail when T
118// has several constructors/operator= (see https://github.com/nlohmann/json/issues/958)
119template <typename BasicJsonType, typename T>
121{
123};
124
125template<typename BasicJsonType, typename T>
126struct has_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
127{
128 using serializer = typename BasicJsonType::template json_serializer<T, void>;
129
130 static constexpr bool value =
132 const BasicJsonType&, T&>::value;
133};
134
135// This trait checks if JSONSerializer<T>::from_json(json const&) exists
136// this overload is used for non-default-constructible user-defined-types
137template<typename BasicJsonType, typename T, typename = void>
138struct has_non_default_from_json : std::false_type {};
139
140template<typename BasicJsonType, typename T>
141struct has_non_default_from_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
142{
143 using serializer = typename BasicJsonType::template json_serializer<T, void>;
144
145 static constexpr bool value =
147 const BasicJsonType&>::value;
148};
149
150// This trait checks if BasicJsonType::json_serializer<T>::to_json exists
151// Do not evaluate the trait when T is a basic_json type, to avoid template instantiation infinite recursion.
152template<typename BasicJsonType, typename T, typename = void>
153struct has_to_json : std::false_type {};
154
155template<typename BasicJsonType, typename T>
156struct has_to_json < BasicJsonType, T, enable_if_t < !is_basic_json<T>::value >>
157{
158 using serializer = typename BasicJsonType::template json_serializer<T, void>;
159
160 static constexpr bool value =
161 is_detected_exact<void, to_json_function, serializer, BasicJsonType&,
162 T>::value;
163};
164
165template<typename T>
166using detect_key_compare = typename T::key_compare;
167
168template<typename T>
169struct has_key_compare : std::integral_constant<bool, is_detected<detect_key_compare, T>::value> {};
170
171// obtains the actual object key comparator
172template<typename BasicJsonType>
174{
175 using object_t = typename BasicJsonType::object_t;
176 using object_comparator_t = typename BasicJsonType::default_object_comparator_t;
177 using type = typename std::conditional < has_key_compare<object_t>::value,
178 typename object_t::key_compare, object_comparator_t>::type;
179};
180
181template<typename BasicJsonType>
183
184///////////////////
185// is_ functions //
186///////////////////
187
188// https://en.cppreference.com/w/cpp/types/conjunction
189template<class...> struct conjunction : std::true_type { };
190template<class B> struct conjunction<B> : B { };
191template<class B, class... Bn>
192struct conjunction<B, Bn...>
193: std::conditional<static_cast<bool>(B::value), conjunction<Bn...>, B>::type {};
194
195// https://en.cppreference.com/w/cpp/types/negation
196template<class B> struct negation : std::integral_constant < bool, !B::value > { };
197
198// Reimplementation of is_constructible and is_default_constructible, due to them being broken for
199// std::pair and std::tuple until LWG 2367 fix (see https://cplusplus.github.io/LWG/lwg-defects.html#2367).
200// This causes compile errors in e.g. clang 3.5 or gcc 4.9.
201template <typename T>
202struct is_default_constructible : std::is_default_constructible<T> {};
203
204template <typename T1, typename T2>
205struct is_default_constructible<std::pair<T1, T2>>
206 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
207
208template <typename T1, typename T2>
209struct is_default_constructible<const std::pair<T1, T2>>
210 : conjunction<is_default_constructible<T1>, is_default_constructible<T2>> {};
211
212template <typename... Ts>
213struct is_default_constructible<std::tuple<Ts...>>
214 : conjunction<is_default_constructible<Ts>...> {};
215
216template <typename... Ts>
217struct is_default_constructible<const std::tuple<Ts...>>
218 : conjunction<is_default_constructible<Ts>...> {};
219
220
221template <typename T, typename... Args>
222struct is_constructible : std::is_constructible<T, Args...> {};
223
224template <typename T1, typename T2>
225struct is_constructible<std::pair<T1, T2>> : is_default_constructible<std::pair<T1, T2>> {};
226
227template <typename T1, typename T2>
228struct is_constructible<const std::pair<T1, T2>> : is_default_constructible<const std::pair<T1, T2>> {};
229
230template <typename... Ts>
231struct is_constructible<std::tuple<Ts...>> : is_default_constructible<std::tuple<Ts...>> {};
232
233template <typename... Ts>
234struct is_constructible<const std::tuple<Ts...>> : is_default_constructible<const std::tuple<Ts...>> {};
235
236
237template<typename T, typename = void>
238struct is_iterator_traits : std::false_type {};
239
240template<typename T>
242{
243 private:
245
246 public:
247 static constexpr auto value =
253};
254
255template<typename T>
257{
258 private:
259 using t_ref = typename std::add_lvalue_reference<T>::type;
260
261 using iterator = detected_t<result_of_begin, t_ref>;
262 using sentinel = detected_t<result_of_end, t_ref>;
263
264 // to be 100% correct, it should use https://en.cppreference.com/w/cpp/iterator/input_or_output_iterator
265 // and https://en.cppreference.com/w/cpp/iterator/sentinel_for
266 // but reimplementing these would be too much work, as a lot of other concepts are used underneath
267 static constexpr auto is_iterator_begin =
269
270 public:
271 static constexpr bool value = !std::is_same<iterator, nonesuch>::value && !std::is_same<sentinel, nonesuch>::value && is_iterator_begin;
272};
273
274template<typename R>
275using iterator_t = enable_if_t<is_range<R>::value, result_of_begin<decltype(std::declval<R&>())>>;
276
277template<typename T>
279
280// The following implementation of is_complete_type is taken from
281// https://blogs.msdn.microsoft.com/vcblog/2015/12/02/partial-support-for-expression-sfinae-in-vs-2015-update-1/
282// and is written by Xiang Fan who agreed to using it in this library.
283
284template<typename T, typename = void>
285struct is_complete_type : std::false_type {};
286
287template<typename T>
288struct is_complete_type<T, decltype(void(sizeof(T)))> : std::true_type {};
289
290template<typename BasicJsonType, typename CompatibleObjectType,
291 typename = void>
292struct is_compatible_object_type_impl : std::false_type {};
293
294template<typename BasicJsonType, typename CompatibleObjectType>
296 BasicJsonType, CompatibleObjectType,
297 enable_if_t < is_detected<mapped_type_t, CompatibleObjectType>::value&&
298 is_detected<key_type_t, CompatibleObjectType>::value >>
299{
300 using object_t = typename BasicJsonType::object_t;
301
302 // macOS's is_constructible does not play well with nonesuch...
303 static constexpr bool value =
304 is_constructible<typename object_t::key_type,
305 typename CompatibleObjectType::key_type>::value &&
306 is_constructible<typename object_t::mapped_type,
307 typename CompatibleObjectType::mapped_type>::value;
308};
309
310template<typename BasicJsonType, typename CompatibleObjectType>
312 : is_compatible_object_type_impl<BasicJsonType, CompatibleObjectType> {};
313
314template<typename BasicJsonType, typename ConstructibleObjectType,
315 typename = void>
316struct is_constructible_object_type_impl : std::false_type {};
317
318template<typename BasicJsonType, typename ConstructibleObjectType>
320 BasicJsonType, ConstructibleObjectType,
321 enable_if_t < is_detected<mapped_type_t, ConstructibleObjectType>::value&&
322 is_detected<key_type_t, ConstructibleObjectType>::value >>
323{
324 using object_t = typename BasicJsonType::object_t;
325
326 static constexpr bool value =
328 (std::is_move_assignable<ConstructibleObjectType>::value ||
329 std::is_copy_assignable<ConstructibleObjectType>::value) &&
330 (is_constructible<typename ConstructibleObjectType::key_type,
331 typename object_t::key_type>::value &&
332 std::is_same <
333 typename object_t::mapped_type,
334 typename ConstructibleObjectType::mapped_type >::value)) ||
335 (has_from_json<BasicJsonType,
336 typename ConstructibleObjectType::mapped_type>::value ||
338 BasicJsonType,
339 typename ConstructibleObjectType::mapped_type >::value);
340};
341
342template<typename BasicJsonType, typename ConstructibleObjectType>
344 : is_constructible_object_type_impl<BasicJsonType,
345 ConstructibleObjectType> {};
346
347template<typename BasicJsonType, typename CompatibleStringType>
349{
350 static constexpr auto value =
352};
353
354template<typename BasicJsonType, typename ConstructibleStringType>
356{
357 // launder type through decltype() to fix compilation failure on ICPC
358#ifdef __INTEL_COMPILER
359 using laundered_type = decltype(std::declval<ConstructibleStringType>());
360#else
361 using laundered_type = ConstructibleStringType;
362#endif
363
364 static constexpr auto value =
367 is_detected_exact<typename BasicJsonType::string_t::value_type,
369};
370
371template<typename BasicJsonType, typename CompatibleArrayType, typename = void>
372struct is_compatible_array_type_impl : std::false_type {};
373
374template<typename BasicJsonType, typename CompatibleArrayType>
376 BasicJsonType, CompatibleArrayType,
378 is_detected<iterator_t, CompatibleArrayType>::value&&
379 is_iterator_traits<iterator_traits<detected_t<iterator_t, CompatibleArrayType>>>::value&&
380// special case for types like std::filesystem::path whose iterator's value_type are themselves
381// c.f. https://github.com/nlohmann/json/pull/3073
382 !std::is_same<CompatibleArrayType, detected_t<range_value_t, CompatibleArrayType>>::value >>
383{
384 static constexpr bool value =
385 is_constructible<BasicJsonType,
387};
388
389template<typename BasicJsonType, typename CompatibleArrayType>
391 : is_compatible_array_type_impl<BasicJsonType, CompatibleArrayType> {};
392
393template<typename BasicJsonType, typename ConstructibleArrayType, typename = void>
394struct is_constructible_array_type_impl : std::false_type {};
395
396template<typename BasicJsonType, typename ConstructibleArrayType>
398 BasicJsonType, ConstructibleArrayType,
399 enable_if_t<std::is_same<ConstructibleArrayType,
400 typename BasicJsonType::value_type>::value >>
401 : std::true_type {};
402
403template<typename BasicJsonType, typename ConstructibleArrayType>
405 BasicJsonType, ConstructibleArrayType,
406 enable_if_t < !std::is_same<ConstructibleArrayType,
407 typename BasicJsonType::value_type>::value&&
408 !is_compatible_string_type<BasicJsonType, ConstructibleArrayType>::value&&
409 is_default_constructible<ConstructibleArrayType>::value&&
410(std::is_move_assignable<ConstructibleArrayType>::value ||
411 std::is_copy_assignable<ConstructibleArrayType>::value)&&
412is_detected<iterator_t, ConstructibleArrayType>::value&&
413is_iterator_traits<iterator_traits<detected_t<iterator_t, ConstructibleArrayType>>>::value&&
414is_detected<range_value_t, ConstructibleArrayType>::value&&
415// special case for types like std::filesystem::path whose iterator's value_type are themselves
416// c.f. https://github.com/nlohmann/json/pull/3073
417!std::is_same<ConstructibleArrayType, detected_t<range_value_t, ConstructibleArrayType>>::value&&
419 detected_t<range_value_t, ConstructibleArrayType >>::value >>
420{
422
423 static constexpr bool value =
424 std::is_same<value_type,
425 typename BasicJsonType::array_t::value_type>::value ||
426 has_from_json<BasicJsonType,
427 value_type>::value ||
429 BasicJsonType,
430 value_type >::value;
431};
432
433template<typename BasicJsonType, typename ConstructibleArrayType>
435 : is_constructible_array_type_impl<BasicJsonType, ConstructibleArrayType> {};
436
437template<typename RealIntegerType, typename CompatibleNumberIntegerType,
438 typename = void>
439struct is_compatible_integer_type_impl : std::false_type {};
440
441template<typename RealIntegerType, typename CompatibleNumberIntegerType>
443 RealIntegerType, CompatibleNumberIntegerType,
444 enable_if_t < std::is_integral<RealIntegerType>::value&&
445 std::is_integral<CompatibleNumberIntegerType>::value&&
446 !std::is_same<bool, CompatibleNumberIntegerType>::value >>
447{
448 // is there an assert somewhere on overflows?
449 using RealLimits = std::numeric_limits<RealIntegerType>;
450 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
451
452 static constexpr auto value =
453 is_constructible<RealIntegerType,
454 CompatibleNumberIntegerType>::value &&
457};
458
459template<typename RealIntegerType, typename CompatibleNumberIntegerType>
461 : is_compatible_integer_type_impl<RealIntegerType,
462 CompatibleNumberIntegerType> {};
463
464template<typename BasicJsonType, typename CompatibleType, typename = void>
465struct is_compatible_type_impl: std::false_type {};
466
467template<typename BasicJsonType, typename CompatibleType>
469 BasicJsonType, CompatibleType,
470 enable_if_t<is_complete_type<CompatibleType>::value >>
471{
472 static constexpr bool value =
474};
475
476template<typename BasicJsonType, typename CompatibleType>
478 : is_compatible_type_impl<BasicJsonType, CompatibleType> {};
479
480template<typename T1, typename T2>
481struct is_constructible_tuple : std::false_type {};
482
483template<typename T1, typename... Args>
484struct is_constructible_tuple<T1, std::tuple<Args...>> : conjunction<is_constructible<T1, Args>...> {};
485
486template<typename BasicJsonType, typename T>
487struct is_json_iterator_of : std::false_type {};
488
489template<typename BasicJsonType>
490struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::iterator> : std::true_type {};
491
492template<typename BasicJsonType>
493struct is_json_iterator_of<BasicJsonType, typename BasicJsonType::const_iterator> : std::true_type
494{};
495
496// checks if a given type T is a template specialization of Primary
497template<template <typename...> class Primary, typename T>
498struct is_specialization_of : std::false_type {};
499
500template<template <typename...> class Primary, typename... Args>
501struct is_specialization_of<Primary, Primary<Args...>> : std::true_type {};
502
503template<typename T>
505
506// checks if A and B are comparable using Compare functor
507template<typename Compare, typename A, typename B, typename = void>
508struct is_comparable : std::false_type {};
509
510template<typename Compare, typename A, typename B>
511struct is_comparable<Compare, A, B, void_t<
512decltype(std::declval<Compare>()(std::declval<A>(), std::declval<B>())),
513decltype(std::declval<Compare>()(std::declval<B>(), std::declval<A>()))
514>> : std::true_type {};
515
516template<typename T>
518
519// type trait to check if KeyType can be used as object key (without a BasicJsonType)
520// see is_usable_as_basic_json_key_type below
521template<typename Comparator, typename ObjectKeyType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
522 bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
523using is_usable_as_key_type = typename std::conditional <
525 && !(ExcludeObjectKeyType && std::is_same<KeyType,
526 ObjectKeyType>::value)
527 && (!RequireTransparentComparator
530 std::true_type,
531 std::false_type >::type;
532
533// type trait to check if KeyType can be used as object key
534// true if:
535// - KeyType is comparable with BasicJsonType::object_t::key_type
536// - if ExcludeObjectKeyType is true, KeyType is not BasicJsonType::object_t::key_type
537// - the comparator is transparent or RequireTransparentComparator is false
538// - KeyType is not a JSON iterator or json_pointer
539template<typename BasicJsonType, typename KeyTypeCVRef, bool RequireTransparentComparator = true,
540 bool ExcludeObjectKeyType = RequireTransparentComparator, typename KeyType = uncvref_t<KeyTypeCVRef>>
541using is_usable_as_basic_json_key_type = typename std::conditional <
542 is_usable_as_key_type<typename BasicJsonType::object_comparator_t,
543 typename BasicJsonType::object_t::key_type, KeyTypeCVRef,
544 RequireTransparentComparator, ExcludeObjectKeyType>::value
546 std::true_type,
547 std::false_type >::type;
548
549template<typename ObjectType, typename KeyType>
550using detect_erase_with_key_type = decltype(std::declval<ObjectType&>().erase(std::declval<KeyType>()));
551
552// type trait to check if object_t has an erase() member functions accepting KeyType
553template<typename BasicJsonType, typename KeyType>
554using has_erase_with_key_type = typename std::conditional <
557 typename BasicJsonType::object_t, KeyType >::value,
558 std::true_type,
559 std::false_type >::type;
560
561// a naive helper to check if a type is an ordered_map (exploits the fact that
562// ordered_map inherits capacity() from std::vector)
563template <typename T>
565{
566 using one = char;
567
568 struct two
569 {
570 char x[2]; // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
571 };
572
573 template <typename C> static one test( decltype(&C::capacity) ) ;
574 template <typename C> static two test(...);
575
576 enum { value = sizeof(test<T>(nullptr)) == sizeof(char) }; // NOLINT(cppcoreguidelines-pro-type-vararg,hicpp-vararg)
577};
578
579// to avoid useless casts (see https://github.com/nlohmann/json/issues/2893#issuecomment-889152324)
580template < typename T, typename U, enable_if_t < !std::is_same<T, U>::value, int > = 0 >
582{
583 return static_cast<T>(value);
584}
585
586template<typename T, typename U, enable_if_t<std::is_same<T, U>::value, int> = 0>
588{
589 return value;
590}
591
592template<typename... Types>
594
595template<typename... Types>
597
598template<typename... Types>
600
601// there's a disjunction trait in another PR; replace when merged
602template<typename... Types>
603using same_sign = std::integral_constant < bool,
604 all_signed<Types...>::value || all_unsigned<Types...>::value >;
605
606template<typename OfType, typename T>
607using never_out_of_range = std::integral_constant < bool,
608 (std::is_signed<OfType>::value && (sizeof(T) < sizeof(OfType)))
609 || (same_sign<OfType, T>::value && sizeof(OfType) == sizeof(T)) >;
610
611template<typename OfType, typename T,
612 bool OfTypeSigned = std::is_signed<OfType>::value,
613 bool TSigned = std::is_signed<T>::value>
615
616template<typename OfType, typename T>
617struct value_in_range_of_impl2<OfType, T, false, false>
618{
619 static constexpr bool test(T val)
620 {
621 using CommonType = typename std::common_type<OfType, T>::type;
622 return static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
623 }
624};
625
626template<typename OfType, typename T>
627struct value_in_range_of_impl2<OfType, T, true, false>
628{
629 static constexpr bool test(T val)
630 {
631 using CommonType = typename std::common_type<OfType, T>::type;
632 return static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
633 }
634};
635
636template<typename OfType, typename T>
637struct value_in_range_of_impl2<OfType, T, false, true>
638{
639 static constexpr bool test(T val)
640 {
641 using CommonType = typename std::common_type<OfType, T>::type;
642 return val >= 0 && static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
643 }
644};
645
646
647template<typename OfType, typename T>
648struct value_in_range_of_impl2<OfType, T, true, true>
649{
650 static constexpr bool test(T val)
651 {
652 using CommonType = typename std::common_type<OfType, T>::type;
653 return static_cast<CommonType>(val) >= static_cast<CommonType>((std::numeric_limits<OfType>::min)())
654 && static_cast<CommonType>(val) <= static_cast<CommonType>((std::numeric_limits<OfType>::max)());
655 }
656};
657
658template<typename OfType, typename T,
659 bool NeverOutOfRange = never_out_of_range<OfType, T>::value,
662
663template<typename OfType, typename T>
664struct value_in_range_of_impl1<OfType, T, false>
665{
666 static constexpr bool test(T val)
667 {
669 }
670};
671
672template<typename OfType, typename T>
673struct value_in_range_of_impl1<OfType, T, true>
674{
675 static constexpr bool test(T /*val*/)
676 {
677 return true;
678 }
679};
680
681template<typename OfType, typename T>
682inline constexpr bool value_in_range_of(T val)
683{
685}
686
687template<bool Value>
688using bool_constant = std::integral_constant<bool, Value>;
689
690///////////////////////////////////////////////////////////////////////////////
691// is_c_string
692///////////////////////////////////////////////////////////////////////////////
693
694namespace impl
695{
696
697template<typename T>
698inline constexpr bool is_c_string()
699{
700 using TUnExt = typename std::remove_extent<T>::type;
701 using TUnCVExt = typename std::remove_cv<TUnExt>::type;
702 using TUnPtr = typename std::remove_pointer<T>::type;
703 using TUnCVPtr = typename std::remove_cv<TUnPtr>::type;
704 return
705 (std::is_array<T>::value && std::is_same<TUnCVExt, char>::value)
706 || (std::is_pointer<T>::value && std::is_same<TUnCVPtr, char>::value);
707}
708
709} // namespace impl
710
711// checks whether T is a [cv] char */[cv] char[] C string
712template<typename T>
713struct is_c_string : bool_constant<impl::is_c_string<T>()> {};
714
715template<typename T>
717
718///////////////////////////////////////////////////////////////////////////////
719// is_transparent
720///////////////////////////////////////////////////////////////////////////////
721
722namespace impl
723{
724
725template<typename T>
726inline constexpr bool is_transparent()
727{
729}
730
731} // namespace impl
732
733// checks whether T has a member named is_transparent
734template<typename T>
735struct is_transparent : bool_constant<impl::is_transparent<T>()> {};
736
737///////////////////////////////////////////////////////////////////////////////
738
739} // namespace detail
#define WPI_JSON_NAMESPACE_END
Definition: abi_macros.h:59
#define WPI_JSON_NAMESPACE_BEGIN
Definition: abi_macros.h:53
Definition: json_ref.h:23
Definition: core.h:1238
#define WPI_BASIC_JSON_TPL_DECLARATION
Definition: macro_scope.h:236
#define WPI_BASIC_JSON_TPL
Definition: macro_scope.h:245
constexpr bool is_transparent()
Definition: type_traits.h:726
constexpr bool is_c_string()
Definition: type_traits.h:698
detail namespace with internal helper functions
Definition: ranges.h:23
std::is_same< Expected, detected_t< Op, Args... > > is_detected_exact
Definition: detected.h:63
void void_t
Definition: core.h:1510
std::integral_constant< bool, std::numeric_limits< T >::is_signed||std::is_same< T, int128_opt >::value > is_signed
Definition: format.h:811
decltype(T::to_json(std::declval< Args >()...)) to_json_function
Definition: type_traits.h:103
decltype(std::declval< T >().template get< U >()) get_template_function
Definition: type_traits.h:109
typename std::conditional< is_usable_as_key_type< typename BasicJsonType::object_comparator_t, typename BasicJsonType::object_t::key_type, KeyTypeCVRef, RequireTransparentComparator, ExcludeObjectKeyType >::value &&!is_json_iterator_of< BasicJsonType, KeyType >::value, std::true_type, std::false_type >::type is_usable_as_basic_json_key_type
Definition: type_traits.h:547
typename T::pointer pointer_t
Definition: type_traits.h:94
typename T::value_type value_type_t
Definition: type_traits.h:88
T conditional_static_cast(U value)
Definition: type_traits.h:581
typename std::enable_if< B, T >::type enable_if_t
Definition: cpp_future.h:38
typename T::mapped_type mapped_type_t
Definition: type_traits.h:82
decltype(std::begin(std::declval< T & >())) iterator_t
Definition: format.h:551
decltype(T::from_json(std::declval< Args >()...)) from_json_function
Definition: type_traits.h:106
std::integral_constant< bool, Value > bool_constant
Definition: type_traits.h:688
typename T::key_type key_type_t
Definition: type_traits.h:85
constexpr bool value_in_range_of(T val)
Definition: type_traits.h:682
std::integral_constant< bool, all_signed< Types... >::value||all_unsigned< Types... >::value > same_sign
Definition: type_traits.h:604
typename detector< nonesuch, void, Op, Args... >::type detected_t
Definition: detected.h:54
typename std::conditional< is_comparable< Comparator, ObjectKeyType, KeyTypeCVRef >::value &&!(ExcludeObjectKeyType &&std::is_same< KeyType, ObjectKeyType >::value) &&(!RequireTransparentComparator||is_detected< detect_is_transparent, Comparator >::value) &&!is_json_pointer< KeyType >::value, std::true_type, std::false_type >::type is_usable_as_key_type
Definition: type_traits.h:531
typename T::iterator_category iterator_category_t
Definition: type_traits.h:100
typename std::conditional< is_detected< detect_erase_with_key_type, typename BasicJsonType::object_t, KeyType >::value, std::true_type, std::false_type >::type has_erase_with_key_type
Definition: type_traits.h:559
value_type_t< iterator_traits< iterator_t< T > > > range_value_t
Definition: type_traits.h:278
typename actual_object_comparator< BasicJsonType >::type actual_object_comparator_t
Definition: type_traits.h:182
type
Definition: core.h:556
typename T::difference_type difference_type_t
Definition: type_traits.h:91
typename std::remove_cv< typename std::remove_reference< T >::type >::type uncvref_t
Definition: cpp_future.h:24
typename T::is_transparent detect_is_transparent
Definition: type_traits.h:517
typename T::reference reference_t
Definition: type_traits.h:97
bool_constant< is_integral< T >::value &&!std::is_same< T, bool >::value &&!std::is_same< T, char >::value &&!std::is_same< T, wchar_t >::value > is_integer
Definition: format.h:817
decltype(std::declval< ObjectType & >().erase(std::declval< KeyType >())) detect_erase_with_key_type
Definition: type_traits.h:550
typename T::key_compare detect_key_compare
Definition: type_traits.h:166
typename detector< nonesuch, void, Op, Args... >::value_t is_detected
Definition: detected.h:48
std::integral_constant< bool,(std::is_signed< OfType >::value &&(sizeof(T)< sizeof(OfType)))||(same_sign< OfType, T >::value &&sizeof(OfType)==sizeof(T)) > never_out_of_range
Definition: type_traits.h:609
WPILIB_DLLEXPORT void from_json(const wpi::json &json, AprilTagFieldLayout &layout)
WPILIB_DLLEXPORT void to_json(wpi::json &json, const AprilTagFieldLayout &layout)
Definition: array.h:89
UnitTypeLhs() max(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3429
UnitTypeLhs() min(const UnitTypeLhs &lhs, const UnitTypeRhs &rhs)
Definition: base.h:3421
Definition: type_traits.h:174
typename BasicJsonType::object_t object_t
Definition: type_traits.h:175
typename BasicJsonType::default_object_comparator_t object_comparator_t
Definition: type_traits.h:176
typename std::conditional< has_key_compare< object_t >::value, typename object_t::key_compare, object_comparator_t >::type type
Definition: type_traits.h:178
Definition: type_traits.h:190
Definition: type_traits.h:189
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: type_traits.h:128
Definition: type_traits.h:113
Definition: type_traits.h:169
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: type_traits.h:143
Definition: type_traits.h:138
typename BasicJsonType::template json_serializer< T, void > serializer
Definition: type_traits.h:158
Definition: type_traits.h:153
Definition: type_traits.h:62
Definition: type_traits.h:49
Definition: type_traits.h:713
Definition: type_traits.h:508
Definition: type_traits.h:372
Definition: type_traits.h:391
Definition: type_traits.h:439
Definition: type_traits.h:462
Definition: type_traits.h:292
Definition: type_traits.h:312
Definition: type_traits.h:349
Definition: type_traits.h:465
Definition: type_traits.h:478
Definition: type_traits.h:285
Definition: type_traits.h:394
Definition: type_traits.h:435
Definition: type_traits.h:316
Definition: type_traits.h:345
Definition: type_traits.h:356
ConstructibleStringType laundered_type
Definition: type_traits.h:361
static constexpr auto value
Definition: type_traits.h:364
Definition: type_traits.h:481
Definition: type_traits.h:222
Definition: type_traits.h:202
Definition: type_traits.h:121
Definition: format.h:804
Definition: type_traits.h:238
Definition: type_traits.h:487
Definition: type_traits.h:72
Definition: type_traits.h:569
char x[2]
Definition: type_traits.h:570
Definition: type_traits.h:565
static one test(decltype(&C::capacity))
char one
Definition: type_traits.h:566
static two test(...)
Definition: type_traits.h:257
static constexpr bool value
Definition: type_traits.h:271
Definition: type_traits.h:498
Definition: type_traits.h:735
Definition: iterator_traits.h:41
Definition: type_traits.h:196
static constexpr bool test(T val)
Definition: type_traits.h:666
static constexpr bool test(T)
Definition: type_traits.h:675
Definition: type_traits.h:661
static constexpr bool test(T val)
Definition: type_traits.h:619
static constexpr bool test(T val)
Definition: type_traits.h:639
static constexpr bool test(T val)
Definition: type_traits.h:629
static constexpr bool test(T val)
Definition: type_traits.h:650
Definition: type_traits.h:614