mirror of
https://github.com/nlohmann/json.git
synced 2025-07-28 12:02:00 +03:00
🔀 merge develop
This commit is contained in:
@ -4952,7 +4952,14 @@ template < typename BasicJsonType, typename T, std::size_t... Idx >
|
|||||||
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(BasicJsonType&& j,
|
||||||
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||||
{
|
{
|
||||||
return { { std::forward<BasicJsonType>(j).at(Idx).template get<T>()... } };
|
return { { std::forward<BasicJsonType>(j).at(Idx).template get < T&& > ()... } };
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename BasicJsonType, typename T, std::size_t... Idx >
|
||||||
|
std::array<T, sizeof...(Idx)> from_json_inplace_array_impl(const BasicJsonType& j,
|
||||||
|
identity_tag<std::array<T, sizeof...(Idx)>> /*unused*/, index_sequence<Idx...> /*unused*/)
|
||||||
|
{
|
||||||
|
return { { j.at(Idx).template get<T>()... } };
|
||||||
}
|
}
|
||||||
|
|
||||||
template < typename BasicJsonType, typename T, std::size_t N >
|
template < typename BasicJsonType, typename T, std::size_t N >
|
||||||
@ -5048,6 +5055,12 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
template<typename BasicJsonType, typename... Args, std::size_t... Idx>
|
||||||
|
std::tuple<Args...> from_json_tuple_impl_base(const BasicJsonType& j, index_sequence<Idx...> /*unused*/)
|
||||||
|
{
|
||||||
|
return std::make_tuple(j.at(Idx).template get<Args>()...);
|
||||||
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename... Args, std::size_t... Idx>
|
template<typename BasicJsonType, typename... Args, std::size_t... Idx>
|
||||||
std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
|
std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/)
|
||||||
{
|
{
|
||||||
@ -5057,8 +5070,14 @@ std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<
|
|||||||
template < typename BasicJsonType, class A1, class A2 >
|
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*/)
|
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>(),
|
return {std::forward<BasicJsonType>(j).at(0).template get < A1&& > (),
|
||||||
std::forward<BasicJsonType>(j).at(1).template get<A2>()};
|
std::forward<BasicJsonType>(j).at(1).template get < A2&& > ()};
|
||||||
|
}
|
||||||
|
|
||||||
|
template < typename BasicJsonType, class A1, class A2 >
|
||||||
|
std::pair<A1, A2> from_json_tuple_impl(const BasicJsonType& j, identity_tag<std::pair<A1, A2>> /*unused*/, priority_tag<0> /*unused*/)
|
||||||
|
{
|
||||||
|
return {j.at(0).template get<A1>(), j.at(1).template get<A2>()};
|
||||||
}
|
}
|
||||||
|
|
||||||
template<typename BasicJsonType, typename A1, typename A2>
|
template<typename BasicJsonType, typename A1, typename A2>
|
||||||
@ -20582,15 +20601,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
/// @brief move constructor
|
/// @brief move constructor
|
||||||
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
/// @sa https://json.nlohmann.me/api/basic_json/basic_json/
|
||||||
basic_json(basic_json&& other) noexcept
|
basic_json(basic_json&& other) noexcept
|
||||||
: json_base_class_t(std::forward<json_base_class_t>(other)),
|
// check that passed value is valid (has to be done before forwarding)
|
||||||
m_data(std::move(other.m_data))
|
: json_base_class_t((other.assert_invariant(false), std::forward<json_base_class_t>(other))),
|
||||||
|
m_data(std::move(other.m_data))// NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||||
{
|
{
|
||||||
// check that passed value is valid
|
|
||||||
other.assert_invariant(false);
|
|
||||||
|
|
||||||
// invalidate payload
|
// invalidate payload
|
||||||
other.m_data.m_type = value_t::null;
|
other.m_data.m_type = value_t::null; // NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||||
other.m_data.m_value = {};
|
other.m_data.m_value = {};// NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved)
|
||||||
|
|
||||||
set_parents();
|
set_parents();
|
||||||
assert_invariant();
|
assert_invariant();
|
||||||
@ -21382,7 +21399,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
|
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
|
||||||
if (it == m_data.m_value.object->end())
|
if (it == m_data.m_value.object->end())
|
||||||
{
|
{
|
||||||
JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this));
|
JSON_THROW(out_of_range::create(403, "key not found (key is an rvalue and cannot be shown)", this));
|
||||||
}
|
}
|
||||||
return set_parent(it->second);
|
return set_parent(it->second);
|
||||||
}
|
}
|
||||||
@ -21420,7 +21437,7 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
|||||||
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
|
auto it = m_data.m_value.object->find(std::forward<KeyType>(key));
|
||||||
if (it == m_data.m_value.object->end())
|
if (it == m_data.m_value.object->end())
|
||||||
{
|
{
|
||||||
JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward<KeyType>(key)), "' not found"), this));
|
JSON_THROW(out_of_range::create(403, "key not found (key is an rvalue and cannot be shown)", this));
|
||||||
}
|
}
|
||||||
return it->second;
|
return it->second;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user