Skip to content

Commit

Permalink
Fix 'const' qualifier on bool& has no effect
Browse files Browse the repository at this point in the history
Thanks, @georgthegreat, for pointing out this issue.
  • Loading branch information
falbrechtskirchinger committed Aug 5, 2022
1 parent 9e1a7c8 commit b69e4ee
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions include/nlohmann/detail/conversions/to_json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -267,8 +267,10 @@ inline void to_json(BasicJsonType& j, T b) noexcept
external_constructor<value_t::boolean>::construct(j, b);
}

template<typename BasicJsonType,
enable_if_t<std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value, int> = 0>
template < typename BasicJsonType,
enable_if_t <
std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value
&& !std::is_same<std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value, int > = 0 >
inline void to_json(BasicJsonType& j, const std::vector<bool>::reference& b) noexcept
{
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
Expand Down
6 changes: 4 additions & 2 deletions single_include/nlohmann/json.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -5500,8 +5500,10 @@ inline void to_json(BasicJsonType& j, T b) noexcept
external_constructor<value_t::boolean>::construct(j, b);
}

template<typename BasicJsonType,
enable_if_t<std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value, int> = 0>
template < typename BasicJsonType,
enable_if_t <
std::is_convertible<const std::vector<bool>::reference&, typename BasicJsonType::boolean_t>::value
&& !std::is_same<std::vector<bool>::reference, typename BasicJsonType::boolean_t&>::value, int > = 0 >
inline void to_json(BasicJsonType& j, const std::vector<bool>::reference& b) noexcept
{
external_constructor<value_t::boolean>::construct(j, static_cast<typename BasicJsonType::boolean_t>(b));
Expand Down

0 comments on commit b69e4ee

Please sign in to comment.