diff --git a/include/nlohmann/detail/conversions/from_json.hpp b/include/nlohmann/detail/conversions/from_json.hpp index aa2f0cbf4..41146cd21 100644 --- a/include/nlohmann/detail/conversions/from_json.hpp +++ b/include/nlohmann/detail/conversions/from_json.hpp @@ -277,7 +277,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 { { 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 > diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index d68584f97..2db129e56 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -4904,7 +4904,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 { { 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 >