9 #include <nlohmann/json_fwd.hpp>
10 #include <nlohmann/detail/macro_scope.hpp>
30 NLOHMANN_BASIC_JSON_TPL_DECLARATION
34 template<
bool B,
typename T =
void>
35 using enable_if_t =
typename std::enable_if<B, T>::type;
38 using uncvref_t =
typename std::remove_cv<typename std::remove_reference<T>::type>::type;
42 template<std::size_t... Ints>
46 using value_type = std::size_t;
47 static constexpr std::size_t size() noexcept
49 return sizeof...(Ints);
53 template<
class Sequence1,
class Sequence2>
56 template<std::size_t... I1, std::size_t... I2>
60 template<std::
size_t N>
63 typename make_index_sequence < N - N / 2 >::type > {};
68 template<
typename... Ts>
86 template<
class B1,
class... Bn>
87 struct conjunction<B1, Bn...> : std::conditional<bool(B1::value), conjunction<Bn...>, B1>::type {};
89 template<
class B>
struct negation : std::integral_constant<bool, not B::value> {};
101 template <
typename T,
typename =
void>
104 template <
typename T>
107 NLOHMANN_JSON_HAS_HELPER(mapped_type);
108 NLOHMANN_JSON_HAS_HELPER(key_type);
109 NLOHMANN_JSON_HAS_HELPER(value_type);
110 NLOHMANN_JSON_HAS_HELPER(iterator);
112 template<
bool B,
class RealType,
class CompatibleObjectType>
115 template<
class RealType,
class CompatibleObjectType>
118 static constexpr
auto value =
119 std::is_constructible<typename RealType::key_type, typename CompatibleObjectType::key_type>::value and
120 std::is_constructible<typename RealType::mapped_type, typename CompatibleObjectType::mapped_type>::value;
123 template<
class BasicJsonType,
class CompatibleObjectType>
128 has_mapped_type<CompatibleObjectType>,
129 has_key_type<CompatibleObjectType>>::value,
130 typename BasicJsonType::object_t, CompatibleObjectType >::value;
133 template<
typename BasicJsonType,
typename T>
136 static auto constexpr value = std::is_same<T, typename BasicJsonType::iterator>::value or
137 std::is_same<T, typename BasicJsonType::const_iterator>::value or
138 std::is_same<T, typename BasicJsonType::reverse_iterator>::value or
139 std::is_same<T, typename BasicJsonType::const_reverse_iterator>::value;
142 template<
class BasicJsonType,
class CompatibleArrayType>
145 static auto constexpr value =
148 BasicJsonType, CompatibleArrayType>>,
149 negation<std::is_constructible<
typename BasicJsonType::string_t,
150 CompatibleArrayType>>,
152 has_value_type<CompatibleArrayType>,
153 has_iterator<CompatibleArrayType>>::value;
156 template<
bool,
typename,
typename>
159 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
163 using RealLimits = std::numeric_limits<RealIntegerType>;
164 using CompatibleLimits = std::numeric_limits<CompatibleNumberIntegerType>;
166 static constexpr
auto value =
167 std::is_constructible<RealIntegerType, CompatibleNumberIntegerType>::value and
168 CompatibleLimits::is_integer and
169 RealLimits::is_signed == CompatibleLimits::is_signed;
172 template<
typename RealIntegerType,
typename CompatibleNumberIntegerType>
175 static constexpr
auto value =
177 std::is_integral<CompatibleNumberIntegerType>::value and
178 not std::is_same<bool, CompatibleNumberIntegerType>::value,
179 RealIntegerType, CompatibleNumberIntegerType > ::value;
183 template<
typename BasicJsonType,
typename T>
188 template<
typename U,
typename = enable_if_t<std::is_same<
void, decltype(uncvref_t<U>::from_json(
189 std::declval<BasicJsonType>(), std::declval<T&>()))>::value>>
190 static int detect(U&&);
191 static void detect(...);
194 static constexpr
bool value = std::is_integral<decltype(
195 detect(std::declval<
typename BasicJsonType::template json_serializer<T, void>>()))>::value;
200 template<
typename BasicJsonType,
typename T>
206 typename = enable_if_t<std::is_same<
207 T, decltype(uncvref_t<U>::from_json(std::declval<BasicJsonType>()))>::value >>
208 static int detect(U&&);
209 static void detect(...);
212 static constexpr
bool value = std::is_integral<decltype(detect(
213 std::declval<
typename BasicJsonType::template json_serializer<T, void>>()))>::value;
217 template<
typename BasicJsonType,
typename T>
221 template<
typename U,
typename = decltype(uncvref_t<U>::to_json(
222 std::declval<BasicJsonType&>(), std::declval<T>()))>
223 static int detect(U&&);
224 static void detect(...);
227 static constexpr
bool value = std::is_integral<decltype(detect(
228 std::declval<
typename BasicJsonType::template json_serializer<T, void>>()))>::value;
231 template <
typename BasicJsonType,
typename CompatibleCompleteType>
234 static constexpr
bool value =
235 not std::is_base_of<std::istream, CompatibleCompleteType>::value and
236 not std::is_same<BasicJsonType, CompatibleCompleteType>::value and
241 template <
typename BasicJsonType,
typename CompatibleType>
244 is_compatible_complete_type<BasicJsonType, CompatibleType>>
252 static constexpr T value{};