fixed compile error for #1045; to_json for iternation_proxy_internal was needed
This commit is contained in:
parent
8d8f890771
commit
1566ad4053
3 changed files with 29 additions and 5 deletions
|
@ -284,6 +284,16 @@ void to_json(BasicJsonType& j, const std::pair<Args...>& p)
|
||||||
j = {p.first, p.second};
|
j = {p.first, p.second};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename IteratorType> class iteration_proxy; // TODO: Forward decl needed, maybe move somewhere else
|
||||||
|
template<typename BasicJsonType, typename T,
|
||||||
|
enable_if_t<std::is_same<T, typename iteration_proxy<typename BasicJsonType::iterator>::iteration_proxy_internal>::value, int> = 0>
|
||||||
|
void to_json(BasicJsonType& j, T b) noexcept
|
||||||
|
{
|
||||||
|
typename BasicJsonType::object_t tmp_obj;
|
||||||
|
tmp_obj[b.key()] = b.value(); // TODO: maybe there is a better way?
|
||||||
|
external_constructor<value_t::object>::construct(j, std::move(tmp_obj));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
||||||
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...>)
|
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...>)
|
||||||
{
|
{
|
||||||
|
|
|
@ -1516,6 +1516,16 @@ void to_json(BasicJsonType& j, const std::pair<Args...>& p)
|
||||||
j = {p.first, p.second};
|
j = {p.first, p.second};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename IteratorType> class iteration_proxy; // TODO: Forward decl needed, maybe move somewhere else
|
||||||
|
template<typename BasicJsonType, typename T,
|
||||||
|
enable_if_t<std::is_same<T, typename iteration_proxy<typename BasicJsonType::iterator>::iteration_proxy_internal>::value, int> = 0>
|
||||||
|
void to_json(BasicJsonType& j, T b) noexcept
|
||||||
|
{
|
||||||
|
typename BasicJsonType::object_t tmp_obj;
|
||||||
|
tmp_obj[b.key()] = b.value(); // TODO: maybe there is a better way?
|
||||||
|
external_constructor<value_t::object>::construct(j, std::move(tmp_obj));
|
||||||
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
template<typename BasicJsonType, typename Tuple, std::size_t... Idx>
|
||||||
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...>)
|
void to_json_tuple_impl(BasicJsonType& j, const Tuple& t, index_sequence<Idx...>)
|
||||||
{
|
{
|
||||||
|
@ -7804,7 +7814,10 @@ inline void grisu2_digit_gen(char* buffer, int& length, int& decimal_exponent,
|
||||||
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
// = ((p1 ) * 2^-e + (p2 )) * 2^e
|
||||||
// = p1 + p2 * 2^e
|
// = p1 + p2 * 2^e
|
||||||
|
|
||||||
const diyfp one(uint64_t{1} << -M_plus.e, M_plus.e);
|
const diyfp one(uint64_t
|
||||||
|
{
|
||||||
|
1
|
||||||
|
} << -M_plus.e, M_plus.e);
|
||||||
|
|
||||||
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
uint32_t p1 = static_cast<uint32_t>(M_plus.f >> -one.e); // p1 = f div 2^-e (Since -e >= 32, p1 fits into a 32-bit int.)
|
||||||
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
uint64_t p2 = M_plus.f & (one.f - 1); // p2 = f mod 2^-e
|
||||||
|
|
|
@ -1631,9 +1631,10 @@ TEST_CASE("regression tests")
|
||||||
p2.begin(), p2.end(),
|
p2.begin(), p2.end(),
|
||||||
std::inserter(diffs, diffs.end()), [&](const it_type & e1, const it_type & e2) -> bool
|
std::inserter(diffs, diffs.end()), [&](const it_type & e1, const it_type & e2) -> bool
|
||||||
{
|
{
|
||||||
return (e1.key() < e2.key()) and (e1.value() < e2.value());
|
using comper_pair = std::pair<std::string, decltype(e1.value())>; // Trying to avoid unneeded copy
|
||||||
|
return comper_pair(e1.key(), e1.value()) < comper_pair(e2.key(), e2.value()); // Using pair comper
|
||||||
});
|
});
|
||||||
|
|
||||||
CHECK(diffs.size() == 2);
|
CHECK(diffs.size() == 1); // Note the change here, was 2
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue