diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index 455e65be9..1b883a78b 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4952,7 +4952,14 @@ template < typename BasicJsonType, typename T, std::size_t... Idx > std::array from_json_inplace_array_impl(BasicJsonType&& j, identity_tag> /*unused*/, index_sequence /*unused*/) { - return { { std::forward(j).at(Idx).template get()... } }; + return { { std::forward(j).at(Idx).template get < T&& > ()... } }; +} + +template < typename BasicJsonType, typename T, std::size_t... Idx > +std::array from_json_inplace_array_impl(const BasicJsonType& j, + identity_tag> /*unused*/, index_sequence /*unused*/) +{ + return { { j.at(Idx).template get()... } }; } template < typename BasicJsonType, typename T, std::size_t N > @@ -5048,6 +5055,12 @@ inline void from_json(const BasicJsonType& j, ArithmeticType& val) } } +template +std::tuple from_json_tuple_impl_base(const BasicJsonType& j, index_sequence /*unused*/) +{ + return std::make_tuple(j.at(Idx).template get()...); +} + template std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence /*unused*/) { @@ -5057,8 +5070,14 @@ std::tuple from_json_tuple_impl_base(BasicJsonType&& j, index_sequence< template < typename BasicJsonType, class A1, class A2 > std::pair from_json_tuple_impl(BasicJsonType&& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) { - return {std::forward(j).at(0).template get(), - std::forward(j).at(1).template get()}; + return {std::forward(j).at(0).template get < A1&& > (), + std::forward(j).at(1).template get < A2&& > ()}; +} + +template < typename BasicJsonType, class A1, class A2 > +std::pair from_json_tuple_impl(const BasicJsonType& j, identity_tag> /*unused*/, priority_tag<0> /*unused*/) +{ + return {j.at(0).template get(), j.at(1).template get()}; } template @@ -20582,15 +20601,13 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec /// @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(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(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 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec auto it = m_data.m_value.object->find(std::forward(key)); if (it == m_data.m_value.object->end()) { - JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward(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 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec auto it = m_data.m_value.object->find(std::forward(key)); if (it == m_data.m_value.object->end()) { - JSON_THROW(out_of_range::create(403, detail::concat("key '", string_t(std::forward(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; }