diff --git a/include/nlohmann/detail/conversions/to_json.hpp b/include/nlohmann/detail/conversions/to_json.hpp index ba24c118d0..75acd70ce2 100644 --- a/include/nlohmann/detail/conversions/to_json.hpp +++ b/include/nlohmann/detail/conversions/to_json.hpp @@ -267,8 +267,10 @@ inline void to_json(BasicJsonType& j, T b) noexcept external_constructor::construct(j, b); } -template::reference&, typename BasicJsonType::boolean_t>::value, int> = 0> +template < typename BasicJsonType, + enable_if_t < + std::is_convertible::reference&, typename BasicJsonType::boolean_t>::value + && !std::is_same::reference, typename BasicJsonType::boolean_t&>::value, int > = 0 > inline void to_json(BasicJsonType& j, const std::vector::reference& b) noexcept { external_constructor::construct(j, static_cast(b)); diff --git a/single_include/nlohmann/json.hpp b/single_include/nlohmann/json.hpp index beee0136c5..ff60dc6711 100644 --- a/single_include/nlohmann/json.hpp +++ b/single_include/nlohmann/json.hpp @@ -5500,8 +5500,10 @@ inline void to_json(BasicJsonType& j, T b) noexcept external_constructor::construct(j, b); } -template::reference&, typename BasicJsonType::boolean_t>::value, int> = 0> +template < typename BasicJsonType, + enable_if_t < + std::is_convertible::reference&, typename BasicJsonType::boolean_t>::value + && !std::is_same::reference, typename BasicJsonType::boolean_t&>::value, int > = 0 > inline void to_json(BasicJsonType& j, const std::vector::reference& b) noexcept { external_constructor::construct(j, static_cast(b));