🎨 use Clang-Format
This commit is contained in:
102 files changed
+15937
-11289
No files matched your search
@@ -30,7 +30,8 @@
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
template<typename BasicJsonType>
|
||||
inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
|
||||
@@ -43,7 +44,9 @@ inline void from_json(const BasicJsonType& j, typename std::nullptr_t& n)
|
||||
}
|
||||
|
||||
// overloads for basic_json template parameters
|
||||
template<typename BasicJsonType, typename ArithmeticType, enable_if_t<std::is_arithmetic<ArithmeticType>::value && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename ArithmeticType,
|
||||
enable_if_t<std::is_arithmetic<ArithmeticType>::value && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
void get_arithmetic_value(const BasicJsonType& j, ArithmeticType& val)
|
||||
{
|
||||
switch (static_cast<value_t>(j))
|
||||
@@ -96,12 +99,12 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::string_t&
|
||||
s = *j.template get_ptr<const typename BasicJsonType::string_t*>();
|
||||
}
|
||||
|
||||
template<
|
||||
typename BasicJsonType,
|
||||
typename StringType,
|
||||
enable_if_t<
|
||||
std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value && is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value && !std::is_same<typename BasicJsonType::string_t, StringType>::value && !is_json_ref<StringType>::value,
|
||||
int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename StringType,
|
||||
enable_if_t<std::is_assignable<StringType&, const typename BasicJsonType::string_t>::value &&
|
||||
is_detected_exact<typename BasicJsonType::string_t::value_type, value_type_t, StringType>::value &&
|
||||
!std::is_same<typename BasicJsonType::string_t, StringType>::value && !is_json_ref<StringType>::value,
|
||||
int> = 0>
|
||||
inline void from_json(const BasicJsonType& j, StringType& s)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_string()))
|
||||
@@ -185,8 +188,7 @@ inline void from_json_array_impl(const BasicJsonType& j, typename BasicJsonType:
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, std::size_t N>
|
||||
auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr, priority_tag<2> /*unused*/)
|
||||
-> decltype(j.template get<T>(), void())
|
||||
auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr, priority_tag<2> /*unused*/) -> decltype(j.template get<T>(), void())
|
||||
{
|
||||
for (std::size_t i = 0; i < N; ++i)
|
||||
{
|
||||
@@ -194,11 +196,11 @@ auto from_json_array_impl(const BasicJsonType& j, std::array<T, N>& arr, priorit
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType, enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename ConstructibleArrayType,
|
||||
enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, int> = 0>
|
||||
auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<1> /*unused*/)
|
||||
-> decltype(arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()),
|
||||
j.template get<typename ConstructibleArrayType::value_type>(),
|
||||
void())
|
||||
-> decltype(arr.reserve(std::declval<typename ConstructibleArrayType::size_type>()), j.template get<typename ConstructibleArrayType::value_type>(), void())
|
||||
{
|
||||
using std::end;
|
||||
|
||||
@@ -212,29 +214,31 @@ auto from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, p
|
||||
arr = std::move(ret);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType, enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename ConstructibleArrayType,
|
||||
enable_if_t<std::is_assignable<ConstructibleArrayType&, ConstructibleArrayType>::value, int> = 0>
|
||||
inline void from_json_array_impl(const BasicJsonType& j, ConstructibleArrayType& arr, priority_tag<0> /*unused*/)
|
||||
{
|
||||
using std::end;
|
||||
|
||||
ConstructibleArrayType ret;
|
||||
std::transform(
|
||||
j.begin(),
|
||||
j.end(),
|
||||
std::inserter(ret, end(ret)),
|
||||
[](const BasicJsonType& i) {
|
||||
// get<BasicJsonType>() returns *this, this won't call a from_json
|
||||
// method when value_type is BasicJsonType
|
||||
return i.template get<typename ConstructibleArrayType::value_type>();
|
||||
});
|
||||
std::transform(j.begin(), j.end(), std::inserter(ret, end(ret)), [](const BasicJsonType& i) {
|
||||
// get<BasicJsonType>() returns *this, this won't call a from_json
|
||||
// method when value_type is BasicJsonType
|
||||
return i.template get<typename ConstructibleArrayType::value_type>();
|
||||
});
|
||||
arr = std::move(ret);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleArrayType, enable_if_t<is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value && !is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value && !is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value && !std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value && !is_basic_json<ConstructibleArrayType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename ConstructibleArrayType,
|
||||
enable_if_t<is_constructible_array_type<BasicJsonType, ConstructibleArrayType>::value &&
|
||||
!is_constructible_object_type<BasicJsonType, ConstructibleArrayType>::value &&
|
||||
!is_constructible_string_type<BasicJsonType, ConstructibleArrayType>::value &&
|
||||
!std::is_same<ConstructibleArrayType, typename BasicJsonType::binary_t>::value && !is_basic_json<ConstructibleArrayType>::value,
|
||||
int> = 0>
|
||||
auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
|
||||
-> decltype(from_json_array_impl(j, arr, priority_tag<3>{}),
|
||||
j.template get<typename ConstructibleArrayType::value_type>(),
|
||||
void())
|
||||
-> decltype(from_json_array_impl(j, arr, priority_tag<3>{}), j.template get<typename ConstructibleArrayType::value_type>(), void())
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
|
||||
{
|
||||
@@ -245,9 +249,8 @@ auto from_json(const BasicJsonType& j, ConstructibleArrayType& arr)
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T, std::size_t... Idx>
|
||||
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
||||
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/,
|
||||
index_sequence<Idx...> /*unused*/)
|
||||
std::array<T, sizeof...(Idx)>
|
||||
from_json_inplace_array_impl(BasicJsonType&& j, identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||
{
|
||||
return {{std::forward<BasicJsonType>(j).at(Idx).template get<T>()...}};
|
||||
}
|
||||
@@ -275,7 +278,9 @@ inline void from_json(const BasicJsonType& j, typename BasicJsonType::binary_t&
|
||||
bin = *j.template get_ptr<const typename BasicJsonType::binary_t*>();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename ConstructibleObjectType, enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename ConstructibleObjectType,
|
||||
enable_if_t<is_constructible_object_type<BasicJsonType, ConstructibleObjectType>::value, int> = 0>
|
||||
inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_object()))
|
||||
@@ -286,13 +291,9 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
|
||||
ConstructibleObjectType ret;
|
||||
const auto* inner_object = j.template get_ptr<const typename BasicJsonType::object_t*>();
|
||||
using value_type = typename ConstructibleObjectType::value_type;
|
||||
std::transform(
|
||||
inner_object->begin(),
|
||||
inner_object->end(),
|
||||
std::inserter(ret, ret.begin()),
|
||||
[](typename BasicJsonType::object_t::value_type const& p) {
|
||||
return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
|
||||
});
|
||||
std::transform(inner_object->begin(), inner_object->end(), std::inserter(ret, ret.begin()), [](typename BasicJsonType::object_t::value_type const& p) {
|
||||
return value_type(p.first, p.second.template get<typename ConstructibleObjectType::mapped_type>());
|
||||
});
|
||||
obj = std::move(ret);
|
||||
}
|
||||
|
||||
@@ -300,7 +301,13 @@ inline void from_json(const BasicJsonType& j, ConstructibleObjectType& obj)
|
||||
// (BooleanType, etc..); note: Is it really necessary to provide explicit
|
||||
// overloads for boolean_t etc. in case of a custom BooleanType which is not
|
||||
// an arithmetic type?
|
||||
template<typename BasicJsonType, typename ArithmeticType, enable_if_t<std::is_arithmetic<ArithmeticType>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value && !std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename ArithmeticType,
|
||||
enable_if_t<std::is_arithmetic<ArithmeticType>::value && !std::is_same<ArithmeticType, typename BasicJsonType::number_unsigned_t>::value &&
|
||||
!std::is_same<ArithmeticType, typename BasicJsonType::number_integer_t>::value &&
|
||||
!std::is_same<ArithmeticType, typename BasicJsonType::number_float_t>::value &&
|
||||
!std::is_same<ArithmeticType, typename BasicJsonType::boolean_t>::value,
|
||||
int> = 0>
|
||||
inline void from_json(const BasicJsonType& j, ArithmeticType& val)
|
||||
{
|
||||
switch (static_cast<value_t>(j))
|
||||
@@ -346,8 +353,7 @@ std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<
|
||||
template<typename BasicJsonType, class A1, class A2>
|
||||
std::pair<A1, A2> from_json_tuple_impl(BasicJsonType&& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
|
||||
{
|
||||
return {std::forward<BasicJsonType>(j).at(0).template get<A1>(),
|
||||
std::forward<BasicJsonType>(j).at(1).template get<A2>()};
|
||||
return {std::forward<BasicJsonType>(j).at(0).template get<A1>(), std::forward<BasicJsonType>(j).at(1).template get<A2>()};
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename A1, typename A2>
|
||||
@@ -380,7 +386,12 @@ auto from_json(BasicJsonType&& j, TupleRelated&& t)
|
||||
return from_json_tuple_impl(std::forward<BasicJsonType>(j), std::forward<TupleRelated>(t), priority_tag<3>{});
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename Key, typename Value, typename Compare, typename Allocator, typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
|
||||
template<typename BasicJsonType,
|
||||
typename Key,
|
||||
typename Value,
|
||||
typename Compare,
|
||||
typename Allocator,
|
||||
typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
|
||||
inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allocator>& m)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
|
||||
@@ -398,7 +409,13 @@ inline void from_json(const BasicJsonType& j, std::map<Key, Value, Compare, Allo
|
||||
}
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename Key, typename Value, typename Hash, typename KeyEqual, typename Allocator, typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
|
||||
template<typename BasicJsonType,
|
||||
typename Key,
|
||||
typename Value,
|
||||
typename Hash,
|
||||
typename KeyEqual,
|
||||
typename Allocator,
|
||||
typename = enable_if_t<!std::is_constructible<typename BasicJsonType::string_t, Key>::value>>
|
||||
inline void from_json(const BasicJsonType& j, std::unordered_map<Key, Value, Hash, KeyEqual, Allocator>& m)
|
||||
{
|
||||
if (JSON_HEDLEY_UNLIKELY(!j.is_array()))
|
||||
@@ -431,9 +448,8 @@ inline void from_json(const BasicJsonType& j, std_fs::path& p)
|
||||
struct from_json_fn
|
||||
{
|
||||
template<typename BasicJsonType, typename T>
|
||||
auto operator()(const BasicJsonType& j, T&& val) const
|
||||
noexcept(noexcept(from_json(j, std::forward<T>(val))))
|
||||
-> decltype(from_json(j, std::forward<T>(val)))
|
||||
auto operator()(const BasicJsonType& j, T&& val) const noexcept(noexcept(from_json(j, std::forward<T>(val))))
|
||||
-> decltype(from_json(j, std::forward<T>(val)))
|
||||
{
|
||||
return from_json(j, std::forward<T>(val));
|
||||
}
|
||||
|
||||
@@ -19,7 +19,8 @@
|
||||
#include <nlohmann/detail/macro_scope.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
/*!
|
||||
@brief implements the Grisu2 algorithm for binary to decimal floating-point
|
||||
@@ -40,7 +41,8 @@ For a detailed description of the algorithm see:
|
||||
Proceedings of the ACM SIGPLAN 1996 Conference on Programming Language
|
||||
Design and Implementation, PLDI 1996
|
||||
*/
|
||||
namespace dtoa_impl {
|
||||
namespace dtoa_impl
|
||||
{
|
||||
|
||||
template<typename Target, typename Source>
|
||||
Target reinterpret_bits(const Source source)
|
||||
@@ -199,8 +201,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
// If v is normalized:
|
||||
// value = 1.F * 2^(E - bias) = (2^(p-1) + F) * 2^(E - bias - (p-1))
|
||||
|
||||
static_assert(std::numeric_limits<FloatType>::is_iec559,
|
||||
"internal error: dtoa_short requires an IEEE-754 floating-point implementation");
|
||||
static_assert(std::numeric_limits<FloatType>::is_iec559, "internal error: dtoa_short requires an IEEE-754 floating-point implementation");
|
||||
|
||||
constexpr int kPrecision = std::numeric_limits<FloatType>::digits; // = p (includes the hidden bit)
|
||||
constexpr int kBias = std::numeric_limits<FloatType>::max_exponent - 1 + (kPrecision - 1);
|
||||
@@ -214,9 +215,7 @@ boundaries compute_boundaries(FloatType value)
|
||||
const std::uint64_t F = bits & (kHiddenBit - 1);
|
||||
|
||||
const bool is_denormal = E == 0;
|
||||
const diyfp v = is_denormal
|
||||
? diyfp(F, kMinExp)
|
||||
: diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
|
||||
const diyfp v = is_denormal ? diyfp(F, kMinExp) : diyfp(F + kHiddenBit, static_cast<int>(E) - kBias);
|
||||
|
||||
// Compute the boundaries m- and m+ of the floating-point value
|
||||
// v = f * 2^e.
|
||||
@@ -241,9 +240,8 @@ boundaries compute_boundaries(FloatType value)
|
||||
|
||||
const bool lower_boundary_is_closer = F == 0 && E > 1;
|
||||
const diyfp m_plus = diyfp(2 * v.f + 1, v.e - 1);
|
||||
const diyfp m_minus = lower_boundary_is_closer
|
||||
? diyfp(4 * v.f - 1, v.e - 2) // (B)
|
||||
: diyfp(2 * v.f - 1, v.e - 1); // (A)
|
||||
const diyfp m_minus = lower_boundary_is_closer ? diyfp(4 * v.f - 1, v.e - 2) // (B)
|
||||
: diyfp(2 * v.f - 1, v.e - 1); // (A)
|
||||
|
||||
// Determine the normalized w+ = m+.
|
||||
const diyfp w_plus = diyfp::normalize(m_plus);
|
||||
@@ -381,89 +379,28 @@ inline cached_power get_cached_power_for_binary_exponent(int e)
|
||||
constexpr int kCachedPowersMinDecExp = -300;
|
||||
constexpr int kCachedPowersDecStep = 8;
|
||||
|
||||
static constexpr std::array<cached_power, 79> kCachedPowers =
|
||||
{
|
||||
{
|
||||
{0xAB70FE17C79AC6CA, -1060, -300},
|
||||
{0xFF77B1FCBEBCDC4F, -1034, -292},
|
||||
{0xBE5691EF416BD60C, -1007, -284},
|
||||
{0x8DD01FAD907FFC3C, -980, -276},
|
||||
{0xD3515C2831559A83, -954, -268},
|
||||
{0x9D71AC8FADA6C9B5, -927, -260},
|
||||
{0xEA9C227723EE8BCB, -901, -252},
|
||||
{0xAECC49914078536D, -874, -244},
|
||||
{0x823C12795DB6CE57, -847, -236},
|
||||
{0xC21094364DFB5637, -821, -228},
|
||||
{0x9096EA6F3848984F, -794, -220},
|
||||
{0xD77485CB25823AC7, -768, -212},
|
||||
{0xA086CFCD97BF97F4, -741, -204},
|
||||
{0xEF340A98172AACE5, -715, -196},
|
||||
{0xB23867FB2A35B28E, -688, -188},
|
||||
{0x84C8D4DFD2C63F3B, -661, -180},
|
||||
{0xC5DD44271AD3CDBA, -635, -172},
|
||||
{0x936B9FCEBB25C996, -608, -164},
|
||||
{0xDBAC6C247D62A584, -582, -156},
|
||||
{0xA3AB66580D5FDAF6, -555, -148},
|
||||
{0xF3E2F893DEC3F126, -529, -140},
|
||||
{0xB5B5ADA8AAFF80B8, -502, -132},
|
||||
{0x87625F056C7C4A8B, -475, -124},
|
||||
{0xC9BCFF6034C13053, -449, -116},
|
||||
{0x964E858C91BA2655, -422, -108},
|
||||
{0xDFF9772470297EBD, -396, -100},
|
||||
{0xA6DFBD9FB8E5B88F, -369, -92},
|
||||
{0xF8A95FCF88747D94, -343, -84},
|
||||
{0xB94470938FA89BCF, -316, -76},
|
||||
{0x8A08F0F8BF0F156B, -289, -68},
|
||||
{0xCDB02555653131B6, -263, -60},
|
||||
{0x993FE2C6D07B7FAC, -236, -52},
|
||||
{0xE45C10C42A2B3B06, -210, -44},
|
||||
{0xAA242499697392D3, -183, -36},
|
||||
{0xFD87B5F28300CA0E, -157, -28},
|
||||
{0xBCE5086492111AEB, -130, -20},
|
||||
{0x8CBCCC096F5088CC, -103, -12},
|
||||
{0xD1B71758E219652C, -77, -4},
|
||||
{0x9C40000000000000, -50, 4},
|
||||
{0xE8D4A51000000000, -24, 12},
|
||||
{0xAD78EBC5AC620000, 3, 20},
|
||||
{0x813F3978F8940984, 30, 28},
|
||||
{0xC097CE7BC90715B3, 56, 36},
|
||||
{0x8F7E32CE7BEA5C70, 83, 44},
|
||||
{0xD5D238A4ABE98068, 109, 52},
|
||||
{0x9F4F2726179A2245, 136, 60},
|
||||
{0xED63A231D4C4FB27, 162, 68},
|
||||
{0xB0DE65388CC8ADA8, 189, 76},
|
||||
{0x83C7088E1AAB65DB, 216, 84},
|
||||
{0xC45D1DF942711D9A, 242, 92},
|
||||
{0x924D692CA61BE758, 269, 100},
|
||||
{0xDA01EE641A708DEA, 295, 108},
|
||||
{0xA26DA3999AEF774A, 322, 116},
|
||||
{0xF209787BB47D6B85, 348, 124},
|
||||
{0xB454E4A179DD1877, 375, 132},
|
||||
{0x865B86925B9BC5C2, 402, 140},
|
||||
{0xC83553C5C8965D3D, 428, 148},
|
||||
{0x952AB45CFA97A0B3, 455, 156},
|
||||
{0xDE469FBD99A05FE3, 481, 164},
|
||||
{0xA59BC234DB398C25, 508, 172},
|
||||
{0xF6C69A72A3989F5C, 534, 180},
|
||||
{0xB7DCBF5354E9BECE, 561, 188},
|
||||
{0x88FCF317F22241E2, 588, 196},
|
||||
{0xCC20CE9BD35C78A5, 614, 204},
|
||||
{0x98165AF37B2153DF, 641, 212},
|
||||
{0xE2A0B5DC971F303A, 667, 220},
|
||||
{0xA8D9D1535CE3B396, 694, 228},
|
||||
{0xFB9B7CD9A4A7443C, 720, 236},
|
||||
{0xBB764C4CA7A44410, 747, 244},
|
||||
{0x8BAB8EEFB6409C1A, 774, 252},
|
||||
{0xD01FEF10A657842C, 800, 260},
|
||||
{0x9B10A4E5E9913129, 827, 268},
|
||||
{0xE7109BFBA19C0C9D, 853, 276},
|
||||
{0xAC2820D9623BF429, 880, 284},
|
||||
{0x80444B5E7AA7CF85, 907, 292},
|
||||
{0xBF21E44003ACDD2D, 933, 300},
|
||||
{0x8E679C2F5E44FF8F, 960, 308},
|
||||
{0xD433179D9C8CB841, 986, 316},
|
||||
{0x9E19DB92B4E31BA9, 1013, 324},
|
||||
}};
|
||||
static constexpr std::array<cached_power, 79> kCachedPowers = {{
|
||||
{0xAB70FE17C79AC6CA, -1060, -300}, {0xFF77B1FCBEBCDC4F, -1034, -292}, {0xBE5691EF416BD60C, -1007, -284}, {0x8DD01FAD907FFC3C, -980, -276},
|
||||
{0xD3515C2831559A83, -954, -268}, {0x9D71AC8FADA6C9B5, -927, -260}, {0xEA9C227723EE8BCB, -901, -252}, {0xAECC49914078536D, -874, -244},
|
||||
{0x823C12795DB6CE57, -847, -236}, {0xC21094364DFB5637, -821, -228}, {0x9096EA6F3848984F, -794, -220}, {0xD77485CB25823AC7, -768, -212},
|
||||
{0xA086CFCD97BF97F4, -741, -204}, {0xEF340A98172AACE5, -715, -196}, {0xB23867FB2A35B28E, -688, -188}, {0x84C8D4DFD2C63F3B, -661, -180},
|
||||
{0xC5DD44271AD3CDBA, -635, -172}, {0x936B9FCEBB25C996, -608, -164}, {0xDBAC6C247D62A584, -582, -156}, {0xA3AB66580D5FDAF6, -555, -148},
|
||||
{0xF3E2F893DEC3F126, -529, -140}, {0xB5B5ADA8AAFF80B8, -502, -132}, {0x87625F056C7C4A8B, -475, -124}, {0xC9BCFF6034C13053, -449, -116},
|
||||
{0x964E858C91BA2655, -422, -108}, {0xDFF9772470297EBD, -396, -100}, {0xA6DFBD9FB8E5B88F, -369, -92}, {0xF8A95FCF88747D94, -343, -84},
|
||||
{0xB94470938FA89BCF, -316, -76}, {0x8A08F0F8BF0F156B, -289, -68}, {0xCDB02555653131B6, -263, -60}, {0x993FE2C6D07B7FAC, -236, -52},
|
||||
{0xE45C10C42A2B3B06, -210, -44}, {0xAA242499697392D3, -183, -36}, {0xFD87B5F28300CA0E, -157, -28}, {0xBCE5086492111AEB, -130, -20},
|
||||
{0x8CBCCC096F5088CC, -103, -12}, {0xD1B71758E219652C, -77, -4}, {0x9C40000000000000, -50, 4}, {0xE8D4A51000000000, -24, 12},
|
||||
{0xAD78EBC5AC620000, 3, 20}, {0x813F3978F8940984, 30, 28}, {0xC097CE7BC90715B3, 56, 36}, {0x8F7E32CE7BEA5C70, 83, 44},
|
||||
{0xD5D238A4ABE98068, 109, 52}, {0x9F4F2726179A2245, 136, 60}, {0xED63A231D4C4FB27, 162, 68}, {0xB0DE65388CC8ADA8, 189, 76},
|
||||
{0x83C7088E1AAB65DB, 216, 84}, {0xC45D1DF942711D9A, 242, 92}, {0x924D692CA61BE758, 269, 100}, {0xDA01EE641A708DEA, 295, 108},
|
||||
{0xA26DA3999AEF774A, 322, 116}, {0xF209787BB47D6B85, 348, 124}, {0xB454E4A179DD1877, 375, 132}, {0x865B86925B9BC5C2, 402, 140},
|
||||
{0xC83553C5C8965D3D, 428, 148}, {0x952AB45CFA97A0B3, 455, 156}, {0xDE469FBD99A05FE3, 481, 164}, {0xA59BC234DB398C25, 508, 172},
|
||||
{0xF6C69A72A3989F5C, 534, 180}, {0xB7DCBF5354E9BECE, 561, 188}, {0x88FCF317F22241E2, 588, 196}, {0xCC20CE9BD35C78A5, 614, 204},
|
||||
{0x98165AF37B2153DF, 641, 212}, {0xE2A0B5DC971F303A, 667, 220}, {0xA8D9D1535CE3B396, 694, 228}, {0xFB9B7CD9A4A7443C, 720, 236},
|
||||
{0xBB764C4CA7A44410, 747, 244}, {0x8BAB8EEFB6409C1A, 774, 252}, {0xD01FEF10A657842C, 800, 260}, {0x9B10A4E5E9913129, 827, 268},
|
||||
{0xE7109BFBA19C0C9D, 853, 276}, {0xAC2820D9623BF429, 880, 284}, {0x80444B5E7AA7CF85, 907, 292}, {0xBF21E44003ACDD2D, 933, 300},
|
||||
{0x8E679C2F5E44FF8F, 960, 308}, {0xD433179D9C8CB841, 986, 316}, {0x9E19DB92B4E31BA9, 1013, 324},
|
||||
}};
|
||||
|
||||
// This computation gives exactly the same results for k as
|
||||
// k = ceil((kAlpha - e - 1) * 0.30102999566398114)
|
||||
@@ -882,8 +819,7 @@ template<typename FloatType>
|
||||
JSON_HEDLEY_NON_NULL(1)
|
||||
void grisu2(char* buf, int& len, int& decimal_exponent, FloatType value)
|
||||
{
|
||||
static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3,
|
||||
"internal error: not enough precision");
|
||||
static_assert(diyfp::kPrecision >= std::numeric_limits<FloatType>::digits + 3, "internal error: not enough precision");
|
||||
|
||||
JSON_ASSERT(std::isfinite(value));
|
||||
JSON_ASSERT(value > 0);
|
||||
@@ -1055,8 +991,7 @@ format. Returns an iterator pointing past-the-end of the decimal representation.
|
||||
*/
|
||||
template<typename FloatType>
|
||||
JSON_HEDLEY_NON_NULL(1, 2)
|
||||
JSON_HEDLEY_RETURNS_NON_NULL
|
||||
char* to_chars(char* first, const char* last, FloatType value)
|
||||
JSON_HEDLEY_RETURNS_NON_NULL char* to_chars(char* first, const char* last, FloatType value)
|
||||
{
|
||||
static_cast<void>(last); // maybe unused - fix warning
|
||||
JSON_ASSERT(std::isfinite(value));
|
||||
|
||||
@@ -25,7 +25,8 @@
|
||||
#include <nlohmann/detail/value_t.hpp>
|
||||
|
||||
NLOHMANN_JSON_NAMESPACE_BEGIN
|
||||
namespace detail {
|
||||
namespace detail
|
||||
{
|
||||
|
||||
//////////////////
|
||||
// constructors //
|
||||
@@ -75,7 +76,9 @@ struct external_constructor<value_t::string>
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleStringType, enable_if_t<!std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleStringType,
|
||||
enable_if_t<!std::is_same<CompatibleStringType, typename BasicJsonType::string_t>::value, int> = 0>
|
||||
static void construct(BasicJsonType& j, const CompatibleStringType& str)
|
||||
{
|
||||
j.m_data.m_value.destroy(j.m_data.m_type);
|
||||
@@ -169,7 +172,9 @@ struct external_constructor<value_t::array>
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleArrayType, enable_if_t<!std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleArrayType,
|
||||
enable_if_t<!std::is_same<CompatibleArrayType, typename BasicJsonType::array_t>::value, int> = 0>
|
||||
static void construct(BasicJsonType& j, const CompatibleArrayType& arr)
|
||||
{
|
||||
using std::begin;
|
||||
@@ -236,7 +241,9 @@ struct external_constructor<value_t::object>
|
||||
j.assert_invariant();
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleObjectType, enable_if_t<!std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleObjectType,
|
||||
enable_if_t<!std::is_same<CompatibleObjectType, typename BasicJsonType::object_t>::value, int> = 0>
|
||||
static void construct(BasicJsonType& j, const CompatibleObjectType& obj)
|
||||
{
|
||||
using std::begin;
|
||||
@@ -260,13 +267,22 @@ inline void to_json(BasicJsonType& j, T b) noexcept
|
||||
external_constructor<value_t::boolean>::construct(j, b);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename BoolRef, enable_if_t<((std::is_same<std::vector<bool>::reference, BoolRef>::value && !std::is_same<std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value) || (std::is_same<std::vector<bool>::const_reference, BoolRef>::value && !std::is_same<detail::uncvref_t<std::vector<bool>::const_reference>, typename BasicJsonType::boolean_t>::value)) && std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename BoolRef,
|
||||
enable_if_t<((std::is_same<std::vector<bool>::reference, BoolRef>::value &&
|
||||
!std::is_same<std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value) ||
|
||||
(std::is_same<std::vector<bool>::const_reference, BoolRef>::value &&
|
||||
!std::is_same<detail::uncvref_t<std::vector<bool>::const_reference>, typename BasicJsonType::boolean_t>::value)) &&
|
||||
std::is_convertible<const BoolRef&, typename BasicJsonType::boolean_t>::value,
|
||||
int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const BoolRef& b) noexcept
|
||||
{
|
||||
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleString, enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleString,
|
||||
enable_if_t<std::is_constructible<typename BasicJsonType::string_t, CompatibleString>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const CompatibleString& s)
|
||||
{
|
||||
external_constructor<value_t::string>::construct(j, s);
|
||||
@@ -284,13 +300,17 @@ inline void to_json(BasicJsonType& j, FloatType val) noexcept
|
||||
external_constructor<value_t::number_float>::construct(j, static_cast<typename BasicJsonType::number_float_t>(val));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleNumberUnsignedType, enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleNumberUnsignedType,
|
||||
enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_unsigned_t, CompatibleNumberUnsignedType>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, CompatibleNumberUnsignedType val) noexcept
|
||||
{
|
||||
external_constructor<value_t::number_unsigned>::construct(j, static_cast<typename BasicJsonType::number_unsigned_t>(val));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleNumberIntegerType, enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleNumberIntegerType,
|
||||
enable_if_t<is_compatible_integer_type<typename BasicJsonType::number_integer_t, CompatibleNumberIntegerType>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, CompatibleNumberIntegerType val) noexcept
|
||||
{
|
||||
external_constructor<value_t::number_integer>::construct(j, static_cast<typename BasicJsonType::number_integer_t>(val));
|
||||
@@ -311,7 +331,13 @@ inline void to_json(BasicJsonType& j, const std::vector<bool>& e)
|
||||
external_constructor<value_t::array>::construct(j, e);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleArrayType, enable_if_t<is_compatible_array_type<BasicJsonType, CompatibleArrayType>::value && !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value && !is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value && !std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value && !is_basic_json<CompatibleArrayType>::value, int> = 0>
|
||||
template<
|
||||
typename BasicJsonType,
|
||||
typename CompatibleArrayType,
|
||||
enable_if_t<is_compatible_array_type<BasicJsonType, CompatibleArrayType>::value && !is_compatible_object_type<BasicJsonType, CompatibleArrayType>::value &&
|
||||
!is_compatible_string_type<BasicJsonType, CompatibleArrayType>::value &&
|
||||
!std::is_same<typename BasicJsonType::binary_t, CompatibleArrayType>::value && !is_basic_json<CompatibleArrayType>::value,
|
||||
int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const CompatibleArrayType& arr)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, arr);
|
||||
@@ -335,7 +361,9 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::array_t&& arr)
|
||||
external_constructor<value_t::array>::construct(j, std::move(arr));
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename CompatibleObjectType, enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value && !is_basic_json<CompatibleObjectType>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename CompatibleObjectType,
|
||||
enable_if_t<is_compatible_object_type<BasicJsonType, CompatibleObjectType>::value && !is_basic_json<CompatibleObjectType>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const CompatibleObjectType& obj)
|
||||
{
|
||||
external_constructor<value_t::object>::construct(j, obj);
|
||||
@@ -347,19 +375,21 @@ inline void to_json(BasicJsonType& j, typename BasicJsonType::object_t&& obj)
|
||||
external_constructor<value_t::object>::construct(j, std::move(obj));
|
||||
}
|
||||
|
||||
template<
|
||||
typename BasicJsonType,
|
||||
typename T,
|
||||
std::size_t N,
|
||||
enable_if_t<!std::is_constructible<typename BasicJsonType::string_t,
|
||||
const T (&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename T,
|
||||
std::size_t N,
|
||||
enable_if_t<!std::is_constructible<typename BasicJsonType::string_t,
|
||||
const T (&)[N]>::value, // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const T (&arr)[N]) // NOLINT(cppcoreguidelines-avoid-c-arrays,hicpp-avoid-c-arrays,modernize-avoid-c-arrays)
|
||||
{
|
||||
external_constructor<value_t::array>::construct(j, arr);
|
||||
}
|
||||
|
||||
template<typename BasicJsonType, typename T1, typename T2, enable_if_t<std::is_constructible<BasicJsonType, T1>::value && std::is_constructible<BasicJsonType, T2>::value, int> = 0>
|
||||
template<typename BasicJsonType,
|
||||
typename T1,
|
||||
typename T2,
|
||||
enable_if_t<std::is_constructible<BasicJsonType, T1>::value && std::is_constructible<BasicJsonType, T2>::value, int> = 0>
|
||||
inline void to_json(BasicJsonType& j, const std::pair<T1, T2>& p)
|
||||
{
|
||||
j = {p.first, p.second};
|
||||
@@ -395,8 +425,7 @@ inline void to_json(BasicJsonType& j, const std_fs::path& p)
|
||||
struct to_json_fn
|
||||
{
|
||||
template<typename BasicJsonType, typename T>
|
||||
auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val))))
|
||||
-> decltype(to_json(j, std::forward<T>(val)), void())
|
||||
auto operator()(BasicJsonType& j, T&& val) const noexcept(noexcept(to_json(j, std::forward<T>(val)))) -> decltype(to_json(j, std::forward<T>(val)), void())
|
||||
{
|
||||
return to_json(j, std::forward<T>(val));
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user