mirror of
https://github.com/nlohmann/json.git
synced 2026-08-31 21:47:15 +00:00
Detect a void-returning erase() through a named trait
erase_from_object() distinguished its two overloads with a decltype of a member call written inline in a default template argument. Every other detection in the library goes through the detector machinery in detected.hpp instead -- has_erase_with_key_type is the same question about the same member function -- and the inline form is the one shape older compilers are least reliable about. Express it the same way: detect_erase_with_iterator plus is_detected_exact, both of which the library already relies on elsewhere. No behaviour changes. Signed-off-by: Niels Lohmann <mail@nlohmann.me>
This commit is contained in:
@@ -788,14 +788,14 @@ class basic_json // NOLINT(cppcoreguidelines-special-member-functions,hicpp-spec
|
||||
/// (e.g., Abseil's hash maps) return void to avoid computing a successor
|
||||
/// the caller may not need. Compute it before erasing for those.
|
||||
template < typename It, detail::enable_if_t <
|
||||
!std::is_void<decltype(std::declval<object_t&>().erase(std::declval<It>()))>::value, int > = 0 >
|
||||
!detail::erase_returns_void<object_t, It>::value, int > = 0 >
|
||||
typename object_t::iterator erase_from_object(It pos)
|
||||
{
|
||||
return m_data.m_value.object->erase(pos);
|
||||
}
|
||||
|
||||
template < typename It, detail::enable_if_t <
|
||||
std::is_void<decltype(std::declval<object_t&>().erase(std::declval<It>()))>::value, int > = 0 >
|
||||
detail::erase_returns_void<object_t, It>::value, int > = 0 >
|
||||
typename object_t::iterator erase_from_object(It pos)
|
||||
{
|
||||
auto next = std::next(pos);
|
||||
|
||||
Reference in New Issue
Block a user