]> gcc.gnu.org Git - gcc.git/commitdiff
libstdc++: Add comparison operators to types from Utilities clause
authorJonathan Wakely <jwakely@redhat.com>
Wed, 15 Apr 2020 18:47:48 +0000 (19:47 +0100)
committerJonathan Wakely <jwakely@redhat.com>
Wed, 15 Apr 2020 18:47:48 +0000 (19:47 +0100)
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.

15 files changed:
libstdc++-v3/ChangeLog
libstdc++-v3/include/bits/allocator.h
libstdc++-v3/include/bits/locale_classes.h
libstdc++-v3/include/bits/std_function.h
libstdc++-v3/include/ext/bitmap_allocator.h
libstdc++-v3/include/ext/debug_allocator.h
libstdc++-v3/include/ext/extptr_allocator.h
libstdc++-v3/include/ext/malloc_allocator.h
libstdc++-v3/include/ext/mt_allocator.h
libstdc++-v3/include/ext/new_allocator.h
libstdc++-v3/include/ext/pool_allocator.h
libstdc++-v3/include/ext/throw_allocator.h
libstdc++-v3/include/std/bitset
libstdc++-v3/include/std/memory_resource
libstdc++-v3/include/std/scoped_allocator

index 696a423e5c71dac9ea3d677f753fdebb185ddf91..ac446acaaac2a587f3f8e5a241896245840bfaa4 100644 (file)
@@ -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.
 
index 3e0d608aa6babd4c569ee59d7e11eb10a0c361b5..ee564791dfaeb0376648f27729ab1e895549bbfb 100644 (file)
@@ -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.
index 11bdddd3dcd5e6a4491a17d2736bf693daaefb69..ab90682cde23acae8e9aaf46a977fa0db37d4e0f 100644 (file)
@@ -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.
index 57375b5de0c5b6feb86f83d753d48412e46ce33e..e2bf9b91850b182816a69eb0d3eedfc0a1d26037 100644 (file)
@@ -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
 
index 97b89e14c8ce3acaf7a815fbb3bb70870d2ab41a..edddf32fb973fea3f72d7343fb626a0c693536c6 100644 (file)
@@ -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; }
+    { return false; }
+#endif
 
   // Static member definitions.
   template<typename _Tp>
index 879bb9cfc05d0595317b46cc9b626e6555ea698d..9946faa10a6db348f0f9f843db74164c6fa8f993 100644 (file)
@@ -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
index 88090548b7cddec7cdd9bf9813f18d8ebfb1f90f..850ca286ef6c96d94d1a190151069d66890db30e 100644 (file)
@@ -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
index e0d59e5620fdfd6de82c86e7669c9db1a7d7a043..1f41660fac7e9676cbdcfc9fc5f6beafd8668bdf 100644 (file)
@@ -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
index 49e0a8ff836ede29e2cd961c5df861674891a8ce..0857390e6654d76cd54b537f3f9445d547f0c495 100644 (file)
@@ -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
 
index 3639f3cbffea42192b22ef62da557f12cba83380..959d6880276892d12e171c9a67403a6267c0e21f 100644 (file)
@@ -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
index cb5bbc2cbb156c215f3985a01a3a1d414bcf1c09..c247c403bec7df57f6c0fc97bf5822651cabf08b 100644 (file)
@@ -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
index 6b0b0a4a150137c59da64cafc6ef6a4188f559b7..f99b26b0cf122fba8dca05a96d5c0d2008e8020f 100644 (file)
@@ -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>
index 93296b9e6238d1b7c3d93f4d3de06ba92988064c..5364e59f4663e86fca01fde21e9bb9320d4d42db 100644 (file)
@@ -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
       //@}
 
       /**
index 74683c5267fcb9d00624fc118b59b877b3b44365..f87ef9688f35f17c72ba6a1b591cbc16b99733a3 100644 (file)
@@ -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
index 8b8866277499ed3aaea5939fdaefaa46a506086e..969b6d8e8c2aba99ab14c73851a09508e42c0caa 100644 (file)
@@ -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
 
   /// @}
 
This page took 0.084511 seconds and 5 git commands to generate.