File indexing completed on 2025-01-18 10:02:19
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010 #pragma once
0011
0012 #include <array> // array
0013 #include <cstddef> // size_t
0014 #include <type_traits> // conditional, enable_if, false_type, integral_constant, is_constructible, is_integral, is_same, remove_cv, remove_reference, true_type
0015 #include <utility> // index_sequence, make_index_sequence, index_sequence_for
0016
0017 #include <nlohmann/detail/macro_scope.hpp>
0018
0019 NLOHMANN_JSON_NAMESPACE_BEGIN
0020 namespace detail
0021 {
0022
0023 template<typename T>
0024 using uncvref_t = typename std::remove_cv<typename std::remove_reference<T>::type>::type;
0025
0026 #ifdef JSON_HAS_CPP_14
0027
0028
0029 using std::enable_if_t;
0030 using std::index_sequence;
0031 using std::make_index_sequence;
0032 using std::index_sequence_for;
0033
0034 #else
0035
0036
0037 template<bool B, typename T = void>
0038 using enable_if_t = typename std::enable_if<B, T>::type;
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051
0052
0053
0054
0055
0056
0057
0058
0059
0060
0061
0062
0063
0064 template <typename T, T... Ints>
0065 struct integer_sequence
0066 {
0067 using value_type = T;
0068 static constexpr std::size_t size() noexcept
0069 {
0070 return sizeof...(Ints);
0071 }
0072 };
0073
0074
0075
0076
0077
0078
0079 template <size_t... Ints>
0080 using index_sequence = integer_sequence<size_t, Ints...>;
0081
0082 namespace utility_internal
0083 {
0084
0085 template <typename Seq, size_t SeqSize, size_t Rem>
0086 struct Extend;
0087
0088
0089 template <typename T, T... Ints, size_t SeqSize>
0090 struct Extend<integer_sequence<T, Ints...>, SeqSize, 0>
0091 {
0092 using type = integer_sequence < T, Ints..., (Ints + SeqSize)... >;
0093 };
0094
0095 template <typename T, T... Ints, size_t SeqSize>
0096 struct Extend<integer_sequence<T, Ints...>, SeqSize, 1>
0097 {
0098 using type = integer_sequence < T, Ints..., (Ints + SeqSize)..., 2 * SeqSize >;
0099 };
0100
0101
0102
0103 template <typename T, size_t N>
0104 struct Gen
0105 {
0106 using type =
0107 typename Extend < typename Gen < T, N / 2 >::type, N / 2, N % 2 >::type;
0108 };
0109
0110 template <typename T>
0111 struct Gen<T, 0>
0112 {
0113 using type = integer_sequence<T>;
0114 };
0115
0116 }
0117
0118
0119
0120
0121
0122
0123
0124
0125 template <typename T, T N>
0126 using make_integer_sequence = typename utility_internal::Gen<T, N>::type;
0127
0128
0129
0130
0131
0132
0133 template <size_t N>
0134 using make_index_sequence = make_integer_sequence<size_t, N>;
0135
0136
0137
0138
0139
0140
0141 template <typename... Ts>
0142 using index_sequence_for = make_index_sequence<sizeof...(Ts)>;
0143
0144
0145
0146 #endif
0147
0148
0149 template<unsigned N> struct priority_tag : priority_tag < N - 1 > {};
0150 template<> struct priority_tag<0> {};
0151
0152
0153 template<typename T>
0154 struct static_const
0155 {
0156 static JSON_INLINE_VARIABLE constexpr T value{};
0157 };
0158
0159 #ifndef JSON_HAS_CPP_17
0160 template<typename T>
0161 constexpr T static_const<T>::value;
0162 #endif
0163
0164 template<typename T, typename... Args>
0165 inline constexpr std::array<T, sizeof...(Args)> make_array(Args&& ... args)
0166 {
0167 return std::array<T, sizeof...(Args)> {{static_cast<T>(std::forward<Args>(args))...}};
0168 }
0169
0170 }
0171 NLOHMANN_JSON_NAMESPACE_END