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.
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.
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.
};
_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.
bool
operator==(const locale& __other) const throw();
+#if __cpp_impl_three_way_comparison < 201907L
/**
* @brief Locale inequality.
*
bool
operator!=(const locale& __other) const throw()
{ return !(this->operator==(__other)); }
+#endif
/**
* @brief Compare two strings according to collate.
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
inline bool
operator!=(nullptr_t, const function<_Res(_Args...)>& __f) noexcept
{ return static_cast<bool>(__f); }
-
+#endif
// [20.7.15.2.7] specialized algorithms
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; }
+ { return false; }
+#endif
// Static member definitions.
template<typename _Tp>
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
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
inline bool
operator!=(const _ExtPtr_allocator& __rarg) const
{ return _M_real_alloc != __rarg._M_real_alloc; }
+#endif
template<typename _Up>
inline friend void
_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
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
_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
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
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>
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
//@}
/**
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>
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
&& __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
/// @}