[2/2] libstdc++/pair: Guard P2321R2 changes with __glibcxx_ranges_zip

Message ID 20240117024003.3390758-2-ppalka@redhat.com
State Accepted
Headers
Series [1/2] libstdc++/tuple: Guard P2321R2 changes with __cpp_lib_ranges_zip |

Checks

Context Check Description
snail/gcc-patch-check success Github commit url

Commit Message

Patrick Palka Jan. 17, 2024, 2:40 a.m. UTC
  Similar to the previous change for <tuple>, but since stl_pair.h is an
internal header we need to use the corresponding internal macro instead.

libstdc++-v3/ChangeLog:

	* include/bits/stl_pair.h [__cplusplus > 202002L]:
	Guard P2321R2 changes with __glibcxx_ranges_zip instead.
---
 libstdc++-v3/include/bits/stl_pair.h | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)
  

Comments

Jonathan Wakely Jan. 17, 2024, 7:43 a.m. UTC | #1
On Wed, 17 Jan 2024 at 02:41, Patrick Palka wrote:
>
> Similar to the previous change for <tuple>, but since stl_pair.h is an
> internal header we need to use the corresponding internal macro instead.

OK thanks.


>
> libstdc++-v3/ChangeLog:
>
>         * include/bits/stl_pair.h [__cplusplus > 202002L]:
>         Guard P2321R2 changes with __glibcxx_ranges_zip instead.
> ---
>  libstdc++-v3/include/bits/stl_pair.h | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
> index 52f532f3c39..acd0c7b58f9 100644
> --- a/libstdc++-v3/include/bits/stl_pair.h
> +++ b/libstdc++-v3/include/bits/stl_pair.h
> @@ -211,7 +211,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>         swap(second, __p.second);
>        }
>
> -#if __cplusplus > 202002L
> +#if __glibcxx_ranges_zip // >= C++23
>        // As an extension, we constrain the const swap member function in order
>        // to continue accepting explicit instantiation of pairs whose elements
>        // are not all const swappable.  Without this constraint, such an
> @@ -360,7 +360,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>         constexpr explicit(!_S_convertible<_U1, _U2>())
>         pair(pair<_U1, _U2>&&) = delete;
>
> -#if __cplusplus > 202002L
> +#if __glibcxx_ranges_zip // >= C++23
>        /// Converting constructor from a non-const `pair<U1, U2>` lvalue
>        template<typename _U1, typename _U2>
>         requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
> @@ -464,7 +464,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>           return *this;
>         }
>
> -#if __cplusplus > 202002L
> +#if __glibcxx_ranges_zip // >= C++23
>        /// Copy assignment operator (const)
>        constexpr const pair&
>        operator=(const pair& __p) const
> @@ -887,7 +887,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>      noexcept(noexcept(__x.swap(__y)))
>      { __x.swap(__y); }
>
> -#if __cplusplus > 202002L
> +#if __glibcxx_ranges_zip // >= C++23
>    template<typename _T1, typename _T2>
>      requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
>      constexpr void
> @@ -1101,7 +1101,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION
>  #endif // __glibcxx_tuples_by_type
>
>
> -#if __cplusplus > 202002L
> +#if __glibcxx_ranges_zip // >= C++23
>    template<typename _T1, typename _T2, typename _U1, typename _U2,
>            template<typename> class _TQual, template<typename> class _UQual>
>      requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,
> --
> 2.43.0.367.g186b115d30
>
  

Patch

diff --git a/libstdc++-v3/include/bits/stl_pair.h b/libstdc++-v3/include/bits/stl_pair.h
index 52f532f3c39..acd0c7b58f9 100644
--- a/libstdc++-v3/include/bits/stl_pair.h
+++ b/libstdc++-v3/include/bits/stl_pair.h
@@ -211,7 +211,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	swap(second, __p.second);
       }
 
-#if __cplusplus > 202002L
+#if __glibcxx_ranges_zip // >= C++23
       // As an extension, we constrain the const swap member function in order
       // to continue accepting explicit instantiation of pairs whose elements
       // are not all const swappable.  Without this constraint, such an
@@ -360,7 +360,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	constexpr explicit(!_S_convertible<_U1, _U2>())
 	pair(pair<_U1, _U2>&&) = delete;
 
-#if __cplusplus > 202002L
+#if __glibcxx_ranges_zip // >= C++23
       /// Converting constructor from a non-const `pair<U1, U2>` lvalue
       template<typename _U1, typename _U2>
 	requires (_S_constructible<_U1&, _U2&>()) && (!_S_dangles<_U1&, _U2&>())
@@ -464,7 +464,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 	  return *this;
 	}
 
-#if __cplusplus > 202002L
+#if __glibcxx_ranges_zip // >= C++23
       /// Copy assignment operator (const)
       constexpr const pair&
       operator=(const pair& __p) const
@@ -887,7 +887,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
     noexcept(noexcept(__x.swap(__y)))
     { __x.swap(__y); }
 
-#if __cplusplus > 202002L
+#if __glibcxx_ranges_zip // >= C++23
   template<typename _T1, typename _T2>
     requires is_swappable_v<const _T1> && is_swappable_v<const _T2>
     constexpr void
@@ -1101,7 +1101,7 @@  _GLIBCXX_BEGIN_NAMESPACE_VERSION
 #endif // __glibcxx_tuples_by_type
 
 
-#if __cplusplus > 202002L
+#if __glibcxx_ranges_zip // >= C++23
   template<typename _T1, typename _T2, typename _U1, typename _U2,
 	   template<typename> class _TQual, template<typename> class _UQual>
     requires requires { typename pair<common_reference_t<_TQual<_T1>, _UQual<_U1>>,