:twisted_rightwards_arrows: merge develop
diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 455e65b..1b883a7 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp
@@ -4952,7 +4952,14 @@ 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>()... } }; + 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 > @@ -5049,6 +5056,12 @@ } 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> std::tuple<Args...> from_json_tuple_impl_base(BasicJsonType&& j, index_sequence<Idx...> /*unused*/) { return std::make_tuple(std::forward<BasicJsonType>(j).at(Idx).template get<Args>()...); @@ -5057,8 +5070,14 @@ 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, 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> @@ -20582,15 +20601,13 @@ /// @brief move constructor /// @sa https://json.nlohmann.me/api/basic_json/basic_json/ basic_json(basic_json&& other) noexcept - : json_base_class_t(std::forward<json_base_class_t>(other)), - m_data(std::move(other.m_data)) + // check that passed value is valid (has to be done before forwarding) + : 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 - other.m_data.m_type = value_t::null; - other.m_data.m_value = {}; + other.m_data.m_type = value_t::null; // NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved) + other.m_data.m_value = {};// NOLINT(bugprone-use-after-move,hicpp-invalid-access-moved) set_parents(); assert_invariant(); @@ -21382,7 +21399,7 @@ auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); 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); } @@ -21420,7 +21437,7 @@ auto it = m_data.m_value.object->find(std::forward<KeyType>(key)); 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; }