Skip to content

Commit

Permalink
fix: crash of value.is<std::string>
Browse files Browse the repository at this point in the history
  • Loading branch information
MistEO committed Feb 2, 2024
1 parent 8e09252 commit 149dc20
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions include/common/value.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,10 +76,12 @@ class basic_value
basic_value(map_t&& map) : basic_value(basic_object<string_t>(std::forward<map_t>(map)))
{}

template <typename jsonization_t, std::enable_if_t<_utils::has_to_json_in_member<jsonization_t>::value, bool> = true>
template <typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_member<jsonization_t>::value, bool> = true>
basic_value(const jsonization_t& jsonization) : basic_value(jsonization.to_json())
{}
template <typename jsonization_t, std::enable_if_t<_utils::has_to_json_in_global<jsonization_t>::value, bool> = true>
template <typename jsonization_t,
std::enable_if_t<_utils::has_to_json_in_global<jsonization_t>::value, bool> = true>
basic_value(const jsonization_t& jsonization) : basic_value(to_json(jsonization))
{}

Expand Down Expand Up @@ -368,6 +370,9 @@ inline bool basic_value<string_t>::is() const noexcept
else if constexpr (std::is_arithmetic_v<value_t>) {
return is_number();
}
else if constexpr (std::is_constructible_v<string_t, value_t>) {
return is_string();
}
else if constexpr (std::is_same_v<basic_array<string_t>, value_t>) {
return is_array();
}
Expand All @@ -381,9 +386,6 @@ inline bool basic_value<string_t>::is() const noexcept
return is_object() && std::is_constructible_v<string_t, typename value_t::key_type> &&
all<typename value_t::mapped_type>();
}
else if constexpr (std::is_constructible_v<string_t, value_t>) {
return is_string();
}
else if constexpr (_utils::has_check_json_in_member<value_t, string_t>::value) {
return value_t().check_json(*this);
}
Expand Down

0 comments on commit 149dc20

Please sign in to comment.