diff --git a/libstdc++-v3/include/bits/ranges_base.h b/libstdc++-v3/include/bits/ranges_base.h index e392c370fcd..25af4b742a6 100644 --- a/libstdc++-v3/include/bits/ranges_base.h +++ b/libstdc++-v3/include/bits/ranges_base.h @@ -91,7 +91,7 @@ namespace ranges using std::ranges::__detail::__maybe_borrowed_range; using std::__detail::__range_iter_t; - struct _Begin final + struct _Begin { private: template @@ -106,8 +106,6 @@ namespace ranges return noexcept(__decay_copy(begin(std::declval<_Tp&>()))); } - void operator&() const = delete; - public: template<__maybe_borrowed_range _Tp> requires is_array_v> || __member_begin<_Tp> @@ -144,7 +142,7 @@ namespace ranges { __decay_copy(end(__t)) } -> sentinel_for<__range_iter_t<_Tp>>; }; - struct _End final + struct _End { private: template @@ -159,8 +157,6 @@ namespace ranges return noexcept(__decay_copy(end(std::declval<_Tp&>()))); } - void operator&() const = delete; - public: template<__maybe_borrowed_range _Tp> requires is_bounded_array_v> @@ -193,7 +189,7 @@ namespace ranges return static_cast(__t); } - struct _CBegin final + struct _CBegin { template constexpr auto @@ -203,8 +199,6 @@ namespace ranges { return _Begin{}(__cust_access::__as_const<_Tp>(__e)); } - - void operator&() const = delete; }; struct _CEnd final @@ -217,8 +211,6 @@ namespace ranges { return _End{}(__cust_access::__as_const<_Tp>(__e)); } - - void operator&() const = delete; }; template @@ -244,7 +236,7 @@ namespace ranges { _End{}(__t) } -> same_as; }; - struct _RBegin final + struct _RBegin { private: template @@ -268,8 +260,6 @@ namespace ranges } } - void operator&() const = delete; - public: template<__maybe_borrowed_range _Tp> requires __member_rbegin<_Tp> || __adl_rbegin<_Tp> || __reversable<_Tp> @@ -304,7 +294,7 @@ namespace ranges -> sentinel_for(__t)))>; }; - struct _REnd final + struct _REnd { private: template @@ -328,8 +318,6 @@ namespace ranges } } - void operator&() const = delete; - public: template<__maybe_borrowed_range _Tp> requires __member_rend<_Tp> || __adl_rend<_Tp> || __reversable<_Tp> @@ -346,7 +334,7 @@ namespace ranges } }; - struct _CRBegin final + struct _CRBegin { template constexpr auto @@ -356,11 +344,9 @@ namespace ranges { return _RBegin{}(__cust_access::__as_const<_Tp>(__e)); } - - void operator&() const = delete; }; - struct _CREnd final + struct _CREnd { template constexpr auto @@ -370,8 +356,6 @@ namespace ranges { return _REnd{}(__cust_access::__as_const<_Tp>(__e)); } - - void operator&() const = delete; }; template @@ -402,7 +386,7 @@ namespace ranges __detail::__to_unsigned_like(_End{}(__t) - _Begin{}(__t)); }; - struct _Size final + struct _Size { private: template @@ -420,8 +404,6 @@ namespace ranges - _Begin{}(std::declval<_Tp&>())); } - void operator&() const = delete; - public: template requires is_bounded_array_v> @@ -440,7 +422,7 @@ namespace ranges } }; - struct _SSize final + struct _SSize { // _GLIBCXX_RESOLVE_LIB_DEFECTS // 3403. Domain of ranges::ssize(E) doesn't match ranges::size(E) @@ -469,8 +451,6 @@ namespace ranges else // Must be one of __max_diff_type or __max_size_type. return __detail::__max_diff_type(__size); } - - void operator&() const = delete; }; template @@ -487,7 +467,7 @@ namespace ranges bool(_Begin{}(__t) == _End{}(__t)); }; - struct _Empty final + struct _Empty { private: template @@ -503,8 +483,6 @@ namespace ranges == _End{}(std::declval<_Tp&>()))); } - void operator&() const = delete; - public: template requires __member_empty<_Tp> || __size0_empty<_Tp> @@ -534,7 +512,7 @@ namespace ranges template concept __begin_data = contiguous_iterator<__range_iter_t<_Tp>>; - struct _Data final + struct _Data { private: template @@ -547,8 +525,6 @@ namespace ranges return noexcept(_Begin{}(std::declval<_Tp&>())); } - void operator&() const = delete; - public: template<__maybe_borrowed_range _Tp> requires __member_data<_Tp> || __begin_data<_Tp> @@ -562,7 +538,7 @@ namespace ranges } }; - struct _CData final + struct _CData { template constexpr auto @@ -572,8 +548,6 @@ namespace ranges { return _Data{}(__cust_access::__as_const<_Tp>(__e)); } - - void operator&() const = delete; }; } // namespace __cust_access diff --git a/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc b/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc index 22030eca9a7..a43448581f3 100644 --- a/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc +++ b/libstdc++-v3/testsuite/24_iterators/customization_points/iter_move.cc @@ -20,6 +20,9 @@ #include #include +#include + +static_assert(__gnu_test::is_customization_point_object(std::ranges::iter_move)); struct X { diff --git a/libstdc++-v3/testsuite/24_iterators/customization_points/iter_swap.cc b/libstdc++-v3/testsuite/24_iterators/customization_points/iter_swap.cc index 35802723d60..f170e177d30 100644 --- a/libstdc++-v3/testsuite/24_iterators/customization_points/iter_swap.cc +++ b/libstdc++-v3/testsuite/24_iterators/customization_points/iter_swap.cc @@ -20,6 +20,9 @@ #include #include +#include + +static_assert(__gnu_test::is_customization_point_object(std::ranges::iter_swap)); struct X { diff --git a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc index 4479c26f30b..ea469e953b2 100644 --- a/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc +++ b/libstdc++-v3/testsuite/std/concepts/concepts.lang/concept.swappable/swap.cc @@ -19,6 +19,10 @@ // { dg-do compile { target c++2a } } #include +#include +#include + +static_assert(__gnu_test::is_customization_point_object(std::ranges::swap)); namespace nu { diff --git a/libstdc++-v3/testsuite/std/ranges/access/begin.cc b/libstdc++-v3/testsuite/std/ranges/access/begin.cc index 6ef44ee631c..a08ad37fd34 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/begin.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/begin.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::begin)); + using std::same_as; void diff --git a/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc b/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc index dc06695139e..ed80af589cf 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/cbegin.cc @@ -20,6 +20,10 @@ #include #include +#include + +static_assert(__gnu_test::is_customization_point_object(std::ranges::cbegin)); + using std::same_as; void diff --git a/libstdc++-v3/testsuite/std/ranges/access/cdata.cc b/libstdc++-v3/testsuite/std/ranges/access/cdata.cc index 2dfb6830789..d51ff1d32eb 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/cdata.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/cdata.cc @@ -20,6 +20,9 @@ #include #include +#include + +static_assert(__gnu_test::is_customization_point_object(std::ranges::cdata)); template concept has_cdata diff --git a/libstdc++-v3/testsuite/std/ranges/access/cend.cc b/libstdc++-v3/testsuite/std/ranges/access/cend.cc index fcb80f28d3a..3e685ae9ce2 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/cend.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/cend.cc @@ -20,6 +20,9 @@ #include #include +#include + +static_assert(__gnu_test::is_customization_point_object(std::ranges::cend)); using std::same_as; diff --git a/libstdc++-v3/testsuite/std/ranges/access/crbegin.cc b/libstdc++-v3/testsuite/std/ranges/access/crbegin.cc index a41234b2dd4..6b02b478a15 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/crbegin.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/crbegin.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::crbegin)); + struct R1 { int i = 0; diff --git a/libstdc++-v3/testsuite/std/ranges/access/crend.cc b/libstdc++-v3/testsuite/std/ranges/access/crend.cc index 8f8b08abd3f..eb010d9d477 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/crend.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/crend.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::crend)); + struct R1 { int i = 0; diff --git a/libstdc++-v3/testsuite/std/ranges/access/data.cc b/libstdc++-v3/testsuite/std/ranges/access/data.cc index 4f16f447f9f..b2083d1890e 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/data.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/data.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::data)); + template concept has_data = requires (T&& t) { std::ranges::data(std::forward(t)); }; diff --git a/libstdc++-v3/testsuite/std/ranges/access/empty.cc b/libstdc++-v3/testsuite/std/ranges/access/empty.cc index b2d8b105325..3cad4740124 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/empty.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/empty.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::empty)); + using std::same_as; void diff --git a/libstdc++-v3/testsuite/std/ranges/access/end.cc b/libstdc++-v3/testsuite/std/ranges/access/end.cc index 7bf0dd44bb3..25f21c75afc 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/end.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/end.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::end)); + using std::same_as; void diff --git a/libstdc++-v3/testsuite/std/ranges/access/rbegin.cc b/libstdc++-v3/testsuite/std/ranges/access/rbegin.cc index a166ad74348..0006f89d4c5 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/rbegin.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/rbegin.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::rbegin)); + struct R1 { int i = 0; diff --git a/libstdc++-v3/testsuite/std/ranges/access/rend.cc b/libstdc++-v3/testsuite/std/ranges/access/rend.cc index 4ba5447c74a..0ac86bc8d4b 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/rend.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/rend.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::rend)); + struct R1 { int i = 0; diff --git a/libstdc++-v3/testsuite/std/ranges/access/size.cc b/libstdc++-v3/testsuite/std/ranges/access/size.cc index f25a1cb9ddb..c7e4f78f96a 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/size.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/size.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::size)); + void test01() { diff --git a/libstdc++-v3/testsuite/std/ranges/access/ssize.cc b/libstdc++-v3/testsuite/std/ranges/access/ssize.cc index fdbf245d036..7337f626a25 100644 --- a/libstdc++-v3/testsuite/std/ranges/access/ssize.cc +++ b/libstdc++-v3/testsuite/std/ranges/access/ssize.cc @@ -22,6 +22,8 @@ #include #include +static_assert(__gnu_test::is_customization_point_object(std::ranges::ssize)); + using std::ptrdiff_t; void diff --git a/libstdc++-v3/testsuite/util/testsuite_iterators.h b/libstdc++-v3/testsuite/util/testsuite_iterators.h index 4e668d648f2..6b835ac475e 100644 --- a/libstdc++-v3/testsuite/util/testsuite_iterators.h +++ b/libstdc++-v3/testsuite/util/testsuite_iterators.h @@ -894,6 +894,22 @@ namespace __gnu_test // This is also true for test_container, although only when it has forward // iterators (because output_iterator_wrapper and input_iterator_wrapper are // not default constructible so do not model std::input_or_output_iterator). + + + // Test for basic properties of C++20 16.3.3.6 [customization.point.object]. + template + constexpr bool + is_customization_point_object(T& obj) noexcept + { + // A [CPO] is a function object with a literal class type. + static_assert( std::is_class_v || std::is_union_v ); + static_assert( __is_literal_type(T) ); + // The type of a [CPO], ignoring cv-qualifiers, shall model semiregular. + static_assert( std::semiregular> ); + + return true; + } + #endif // C++20 } // namespace __gnu_test #endif // _TESTSUITE_ITERATORS