From: Jonathan Wakely Date: Wed, 12 Jun 2024 13:53:00 +0000 (+0100) Subject: libstdc++: Use __glibcxx_ranges_as_const to guard P2278R4 changes X-Git-Tag: basepoints/gcc-16~8296 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0755b2304bac9579fd5da337da8f861ccb1b042b;p=thirdparty%2Fgcc.git libstdc++: Use __glibcxx_ranges_as_const to guard P2278R4 changes The P2278R4 additions for C++23 are currently guarded by a check for __cplusplus > 202002L but can use __glibcxx_ranges_as_const instead. libstdc++-v3/ChangeLog: * include/bits/ranges_base.h (const_iterator_t): Change preprocessor condition to use __glibcxx_ranges_as_const. (const_sentinel_t, range_const_reference_t): Likewise. (__access::__possibly_const_range, cbegin, cend, crbegin) (crend, cdata): Likewise. * include/bits/stl_iterator.h (iter_const_reference_t) (basic_const_iterator, const_iterator, const_sentinel) (make_const_iterator): Likewise. --- diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index 6597ffa532d..23c0b56ff22 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -513,7 +513,7 @@ namespace ranges template using sentinel_t = decltype(ranges::end(std::declval<_Range&>())); -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template using const_iterator_t = const_iterator>; @@ -616,7 +616,7 @@ namespace ranges concept common_range = range<_Tp> && same_as, sentinel_t<_Tp>>; -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template concept constant_range = input_range<_Tp> && std::__detail::__constant_iterator>; @@ -624,7 +624,7 @@ namespace ranges namespace __access { -#if __cplusplus > 202020L +#if __glibcxx_ranges_as_const // >= C++23 template constexpr auto& __possibly_const_range(_Range& __r) noexcept @@ -651,7 +651,7 @@ namespace ranges struct _CBegin { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -679,7 +679,7 @@ namespace ranges struct _CEnd final { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -707,7 +707,7 @@ namespace ranges struct _CRBegin { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -735,7 +735,7 @@ namespace ranges struct _CREnd { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr auto @@ -763,7 +763,7 @@ namespace ranges struct _CData { -#if __cplusplus > 202002L +#if __glibcxx_ranges_as_const // >= C++23 template<__maybe_borrowed_range _Tp> [[nodiscard]] constexpr const auto* diff --git a/libstdc++-v3/include/bits/stl_iterator.h b/libstdc++-v3/include/bits/stl_iterator.h index 560a10a7abe..d3823057270 100644 --- a/libstdc++-v3/include/bits/stl_iterator.h +++ b/libstdc++-v3/include/bits/stl_iterator.h @@ -2571,7 +2571,7 @@ _GLIBCXX_BEGIN_NAMESPACE_VERSION void>; }; -#if __cplusplus > 202020L +#if __glibcxx_ranges_as_const // >= C++23 template using iter_const_reference_t = common_reference_t&&, iter_reference_t<_It>>;