libstdc++: Add comparison operators to types from Utilities clause
Some more C++20 changes from P1614R2, "The Mothership has Landed". This removes all redundant equality and inequality operators in the Utilities clause, as they can be synthesized from the remaining equality operators. It also removes the single redundant operator in the Localization clause, because it didn't seem worth doing in a separate commit. * include/bits/allocator.h (operator!=): Do not define for C++20. * include/bits/locale_classes.h (operator!=): Likewise. * include/bits/std_function.h (operator==(nullptr_t, const function&)) (operator!=(const function&, nullptr_t)) (operator!=(nullptr_t, const function&)): Likewise. * include/ext/bitmap_allocator.h (operator!=): Likewise. * include/ext/debug_allocator.h (operator!=): Likewise. * include/ext/extptr_allocator.h (operator!=): Likewise. * include/ext/malloc_allocator.h (operator!=): Likewise. * include/ext/mt_allocator.h (operator!=): Likewise. * include/ext/new_allocator.h (operator!=): Likewise. * include/ext/pool_allocator.h (operator!=): Likewise. * include/ext/throw_allocator.h (operator!=): Likewise. * include/std/bitset (bitset::operator!=): Likewise. * include/std/memory_resource (operator!=): Likewise. * include/std/scoped_allocator (operator!=): Likewise.
This commit is contained in:
parent
4714fd14af
commit
596676d66c
|
@ -1,5 +1,22 @@
|
|||
2020-04-15 Jonathan Wakely <jwakely@redhat.com>
|
||||
|
||||
* include/bits/allocator.h (operator!=): Do not define for C++20.
|
||||
* include/bits/locale_classes.h (operator!=): Likewise.
|
||||
* include/bits/std_function.h (operator==(nullptr_t, const function&))
|
||||
(operator!=(const function&, nullptr_t))
|
||||
(operator!=(nullptr_t, const function&)): Likewise.
|
||||
* include/ext/bitmap_allocator.h (operator!=): Likewise.
|
||||
* include/ext/debug_allocator.h (operator!=): Likewise.
|
||||
* include/ext/extptr_allocator.h (operator!=): Likewise.
|
||||
* include/ext/malloc_allocator.h (operator!=): Likewise.
|
||||
* include/ext/mt_allocator.h (operator!=): Likewise.
|
||||
* include/ext/new_allocator.h (operator!=): Likewise.
|
||||
* include/ext/pool_allocator.h (operator!=): Likewise.
|
||||
* include/ext/throw_allocator.h (operator!=): Likewise.
|
||||
* include/std/bitset (bitset::operator!=): Likewise.
|
||||
* include/std/memory_resource (operator!=): Likewise.
|
||||
* include/std/scoped_allocator (operator!=): Likewise.
|
||||
|
||||
* include/std/typeindex (operator<=>): Define for C++20.
|
||||
* testsuite/20_util/typeindex/comparison_operators_c++20.cc: New test.
|
||||
|
||||
|
|
|
@ -196,9 +196,11 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
operator==(const allocator&, const allocator&) _GLIBCXX_NOTHROW
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
friend _GLIBCXX20_CONSTEXPR bool
|
||||
operator!=(const allocator&, const allocator&) _GLIBCXX_NOTHROW
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
// Inherit everything else.
|
||||
};
|
||||
|
@ -209,11 +211,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
_GLIBCXX_NOTHROW
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _T1, typename _T2>
|
||||
inline _GLIBCXX20_CONSTEXPR bool
|
||||
operator!=(const allocator<_T1>&, const allocator<_T2>&)
|
||||
_GLIBCXX_NOTHROW
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
// Invalid allocator<cv T> partial specializations.
|
||||
// allocator_traits::rebind_alloc can be used to form a valid allocator type.
|
||||
|
|
|
@ -254,6 +254,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
bool
|
||||
operator==(const locale& __other) const throw();
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
/**
|
||||
* @brief Locale inequality.
|
||||
*
|
||||
|
@ -263,6 +264,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
bool
|
||||
operator!=(const locale& __other) const throw()
|
||||
{ return !(this->operator==(__other)); }
|
||||
#endif
|
||||
|
||||
/**
|
||||
* @brief Compare two strings according to collate.
|
||||
|
|
|
@ -680,6 +680,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
operator==(const function<_Res(_Args...)>& __f, nullptr_t) noexcept
|
||||
{ return !static_cast<bool>(__f); }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
/// @overload
|
||||
template<typename _Res, typename... _Args>
|
||||
inline bool
|
||||
|
@ -703,7 +704,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
inline bool
|
||||
operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
|
||||
{ return static_cast<bool>(__f); }
|
||||
|
||||
#endif
|
||||
|
||||
// [20.7.15.2.7] specialized algorithms
|
||||
|
||||
|
|
|
@ -1098,11 +1098,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
const bitmap_allocator<_Tp2>&) throw()
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Tp1, typename _Tp2>
|
||||
bool
|
||||
operator!=(const bitmap_allocator<_Tp1>&,
|
||||
const bitmap_allocator<_Tp2>&) throw()
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
// Static member definitions.
|
||||
template<typename _Tp>
|
||||
|
|
|
@ -179,11 +179,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
const debug_allocator<_Alloc2>& __rhs) _GLIBCXX_NOTHROW
|
||||
{ return __lhs._M_allocator == debug_allocator(__rhs)._M_allocator; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Alloc2>
|
||||
friend bool
|
||||
operator!=(const debug_allocator& __lhs,
|
||||
const debug_allocator<_Alloc2>& __rhs) _GLIBCXX_NOTHROW
|
||||
{ return !(__lhs == __rhs); }
|
||||
#endif
|
||||
};
|
||||
|
||||
_GLIBCXX_END_NAMESPACE_VERSION
|
||||
|
|
|
@ -138,6 +138,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
operator==(const _ExtPtr_allocator& __rarg) const
|
||||
{ return _M_real_alloc == __rarg._M_real_alloc; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Up>
|
||||
inline bool
|
||||
operator!=(const _ExtPtr_allocator<_Up>& __rarg) const
|
||||
|
@ -146,6 +147,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
inline bool
|
||||
operator!=(const _ExtPtr_allocator& __rarg) const
|
||||
{ return _M_real_alloc != __rarg._M_real_alloc; }
|
||||
#endif
|
||||
|
||||
template<typename _Up>
|
||||
inline friend void
|
||||
|
|
|
@ -174,11 +174,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
_GLIBCXX_NOTHROW
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Up>
|
||||
friend _GLIBCXX20_CONSTEXPR bool
|
||||
operator!=(const malloc_allocator&, const malloc_allocator<_Up>&)
|
||||
_GLIBCXX_NOTHROW
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
_GLIBCXX_CONSTEXPR size_type
|
||||
|
|
|
@ -771,10 +771,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
operator==(const __mt_alloc<_Tp, _Poolp>&, const __mt_alloc<_Tp, _Poolp>&)
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Tp, typename _Poolp>
|
||||
inline bool
|
||||
operator!=(const __mt_alloc<_Tp, _Poolp>&, const __mt_alloc<_Tp, _Poolp>&)
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
#undef __thread_default
|
||||
|
||||
|
|
|
@ -173,11 +173,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
_GLIBCXX_NOTHROW
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Up>
|
||||
friend _GLIBCXX20_CONSTEXPR bool
|
||||
operator!=(const new_allocator&, const new_allocator<_Up>&)
|
||||
_GLIBCXX_NOTHROW
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
private:
|
||||
_GLIBCXX_CONSTEXPR size_type
|
||||
|
|
|
@ -198,10 +198,12 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
operator==(const __pool_alloc<_Tp>&, const __pool_alloc<_Tp>&)
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Tp>
|
||||
inline bool
|
||||
operator!=(const __pool_alloc<_Tp>&, const __pool_alloc<_Tp>&)
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
template<typename _Tp>
|
||||
_Atomic_word
|
||||
|
|
|
@ -895,11 +895,13 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
const throw_allocator_base<_Tp, _Cond>&)
|
||||
{ return true; }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Tp, typename _Cond>
|
||||
inline bool
|
||||
operator!=(const throw_allocator_base<_Tp, _Cond>&,
|
||||
const throw_allocator_base<_Tp, _Cond>&)
|
||||
{ return false; }
|
||||
#endif
|
||||
|
||||
/// Allocator throwing via limit condition.
|
||||
template<typename _Tp>
|
||||
|
|
|
@ -1306,9 +1306,11 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
|
|||
operator==(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
|
||||
{ return this->_M_is_equal(__rhs); }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
bool
|
||||
operator!=(const bitset<_Nb>& __rhs) const _GLIBCXX_NOEXCEPT
|
||||
{ return !this->_M_is_equal(__rhs); }
|
||||
#endif
|
||||
//@}
|
||||
|
||||
/**
|
||||
|
|
|
@ -122,10 +122,11 @@ namespace pmr
|
|||
operator==(const memory_resource& __a, const memory_resource& __b) noexcept
|
||||
{ return &__a == &__b || __a.is_equal(__b); }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
inline bool
|
||||
operator!=(const memory_resource& __a, const memory_resource& __b) noexcept
|
||||
{ return !(__a == __b); }
|
||||
|
||||
#endif
|
||||
|
||||
// C++17 23.12.3 Class template polymorphic_allocator
|
||||
template<typename _Tp>
|
||||
|
@ -362,12 +363,13 @@ namespace pmr
|
|||
const polymorphic_allocator<_Tp2>& __b) noexcept
|
||||
{ return *__a.resource() == *__b.resource(); }
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
template<typename _Tp1, typename _Tp2>
|
||||
inline bool
|
||||
operator!=(const polymorphic_allocator<_Tp1>& __a,
|
||||
const polymorphic_allocator<_Tp2>& __b) noexcept
|
||||
{ return !(__a == __b); }
|
||||
|
||||
#endif
|
||||
|
||||
/// Parameters for tuning a pool resource's behaviour.
|
||||
struct pool_options
|
||||
|
|
|
@ -500,12 +500,14 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
|
|||
&& __a._M_inner == __b._M_inner;
|
||||
}
|
||||
|
||||
#if __cpp_impl_three_way_comparison < 201907L
|
||||
/// @related std::scoped_allocator_adaptor
|
||||
template <typename _OutA1, typename _OutA2, typename... _InA>
|
||||
inline bool
|
||||
operator!=(const scoped_allocator_adaptor<_OutA1, _InA...>& __a,
|
||||
const scoped_allocator_adaptor<_OutA2, _InA...>& __b) noexcept
|
||||
{ return !(__a == __b); }
|
||||
#endif
|
||||
|
||||
/// @}
|
||||
|
||||
|
|
Loading…
Reference in New Issue