diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -119,6 +119,14 @@ requires { typename _ITER_CONCEPT<_Ip>; } && derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>; +// [iterator.concept.forward] +template +concept forward_iterator = + input_iterator<_Ip> && + derived_from<_ITER_CONCEPT<_Ip>, forward_iterator_tag> && + incrementable<_Ip> && + sentinel_for<_Ip, _Ip>; + // clang-format on #endif // !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/libcxx/include/__ranges/concepts.h b/libcxx/include/__ranges/concepts.h --- a/libcxx/include/__ranges/concepts.h +++ b/libcxx/include/__ranges/concepts.h @@ -54,8 +54,12 @@ template concept input_range = range<_Tp> && input_iterator >; + template + concept forward_range = input_range<_Tp> && forward_iterator >; + template concept common_range = range<_Tp> && same_as, sentinel_t<_Tp> >; + } // namespace ranges #endif // !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/libcxx/include/iterator b/libcxx/include/iterator --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -79,6 +79,10 @@ template concept input_iterator = see below; // since C++20 +// [iterator.concept.forward], concept forward_iterator +template + concept forward_iterator = see below; // since C++20 + template struct iterator diff --git a/libcxx/include/ranges b/libcxx/include/ranges --- a/libcxx/include/ranges +++ b/libcxx/include/ranges @@ -51,6 +51,9 @@ template concept input_range = see below; + template + concept forward_range = see below; + template concept common_range = see below; } diff --git a/libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp copy from libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp copy to libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp --- a/libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp +++ b/libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp @@ -11,30 +11,24 @@ // UNSUPPORTED: gcc-10 // XFAIL: msvc && clang -// template -// concept input_iterator; - -#include +// std::forward_iterator; #include -struct range { - int* begin(); - int* end(); -}; +#include // clang-format off -template -requires std::input_iterator > -[[nodiscard]] constexpr bool check_input_range_subsumption() { +template +requires std::derived_from, std::forward_iterator_tag> +[[nodiscard]] constexpr bool check_subsumption() { return false; } -template +template requires true -[[nodiscard]] constexpr bool check_input_range_subsumption() { +[[nodiscard]] constexpr bool check_subsumption() { return true; } // clang-format on -static_assert(check_input_range_subsumption()); +static_assert(check_subsumption()); diff --git a/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/map/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::map::const_reverse_iterator; using value_type = std::pair; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); diff --git a/libcxx/test/std/containers/associative/map/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/map/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/map/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/map/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::multimap::const_reverse_iterator; using value_type = std::pair; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); diff --git a/libcxx/test/std/containers/associative/multimap/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/multimap/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/multimap/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/multimap/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::multiset::const_reverse_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,11 +33,10 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); +static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); diff --git a/libcxx/test/std/containers/associative/multiset/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/multiset/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/multiset/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/multiset/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/set/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::set::const_reverse_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); diff --git a/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/iterator_concept_conformance.compile.pass.cpp @@ -22,10 +22,8 @@ using reverse_iterator = std::array::reverse_iterator; using const_reverse_iterator = std::array::const_reverse_iterator; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,10 +33,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -47,4 +43,3 @@ static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/sequences/array/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/array/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/array/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/array/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::deque::const_reverse_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -36,10 +34,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -48,4 +44,3 @@ static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/sequences/deque/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/deque/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/deque/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/deque/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/forwardlist.iter/iterator_concept_conformance.compile.pass.cpp @@ -21,22 +21,16 @@ using const_iterator = std::forward_list::const_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/sequences/forwardlist/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/forwardlist/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/forwardlist/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/forwardlist/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::list::const_reverse_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -49,4 +44,3 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/sequences/list/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/list/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/list/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/list/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::vector::const_reverse_iterator; using value_type = bool; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -36,10 +34,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -48,4 +44,3 @@ static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/sequences/vector.bool/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector.bool/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/vector.bool/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector.bool/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_reverse_iterator = std::vector::const_reverse_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -36,10 +34,8 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -48,4 +44,3 @@ static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/sequences/vector/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/sequences/vector/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/sequences/vector/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/sequences/vector/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_local_iterator = std::unordered_map::const_local_iterator; using value_type = std::pair; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -49,12 +44,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); @@ -63,12 +55,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); @@ -77,4 +66,3 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/unord/unord.map/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.map/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.map/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.map/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_local_iterator = std::unordered_multimap::const_local_iterator; using value_type = std::pair; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -49,12 +44,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); @@ -63,12 +55,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); @@ -77,4 +66,3 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/unord/unord.multimap/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multimap/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multimap/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multimap/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/iterator_concept_conformance.compile.pass.cpp @@ -23,10 +23,8 @@ using const_local_iterator = std::unordered_multiset::const_local_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -35,12 +33,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); @@ -49,12 +44,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); @@ -63,12 +55,9 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); @@ -77,4 +66,3 @@ static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/containers/unord/unord.multiset/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.multiset/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.multiset/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.multiset/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/iterator_concept_conformance.compile.pass.cpp @@ -23,39 +23,45 @@ using const_local_iterator = std::unordered_set::const_local_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); -static_assert(std::input_iterator); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); static_assert(std::sentinel_for); +static_assert(std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); -static_assert(std::input_iterator); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); +static_assert(std::forward_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); static_assert(std::sentinel_for); -static_assert(std::input_iterator); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sentinel_for); static_assert(std::sentinel_for); -static_assert(std::input_iterator); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); +static_assert(!std::sized_sentinel_for); diff --git a/libcxx/test/std/containers/unord/unord.set/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/unord/unord.set/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/unord/unord.set/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/unord/unord.set/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/views/range_concept_conformance.compile.pass.cpp @@ -23,8 +23,8 @@ static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/views/span.iterators/iterator_concept_conformance.compile.pass.cpp @@ -21,12 +21,9 @@ using reverse_iterator = std::span::reverse_iterator; using value_type = int; -static_assert(std::indirectly_readable); +static_assert(std::forward_iterator); static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); static_assert(std::sized_sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,20 +19,16 @@ using value_type = fs::directory_entry; -static_assert(std::indirectly_readable); +static_assert(std::input_iterator); +static_assert(!std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::weakly_incrementable); static_assert(!std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); -static_assert(std::indirectly_readable); +static_assert(std::input_iterator); +static_assert(!std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::weakly_incrementable); static_assert(!std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.path/range_concept_conformance.compile.pass.cpp @@ -22,8 +22,8 @@ static_assert(std::same_as, fs::path::iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); static_assert(std::same_as, fs::path::const_iterator>); static_assert(stdr::common_range); -static_assert(stdr::input_range); +static_assert(stdr::forward_range); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/forward_iterator.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/forward_iterator.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/forward_iterator.compile.pass.cpp @@ -0,0 +1,90 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts +// UNSUPPORTED: gcc-10 +// XFAIL: msvc && clang + +// std::forward_iterator; + +#include + +#include + +#include "test_iterators.h" + +static_assert(!std::forward_iterator >); +static_assert(!std::forward_iterator >); +static_assert(std::forward_iterator >); +static_assert(std::forward_iterator >); +static_assert(std::forward_iterator >); +static_assert(std::forward_iterator >); + +static_assert(std::forward_iterator); +static_assert(std::forward_iterator); +static_assert(std::forward_iterator); +static_assert(std::forward_iterator); + +struct not_input_iterator { + // using value_type = int; + using difference_type = std::ptrdiff_t; + using iterator_concept = std::forward_iterator_tag; + + int operator*() const; + + not_input_iterator& operator++(); + not_input_iterator operator++(int); + + bool operator==(not_input_iterator const&) const = default; +}; +static_assert(std::input_or_output_iterator); +static_assert(!std::input_iterator); +static_assert(!std::forward_iterator); + +struct bad_iterator_tag { + using value_type = int; + using difference_type = std::ptrdiff_t; + using iterator_concept = std::input_iterator_tag; + + int operator*() const; + + bad_iterator_tag& operator++(); + bad_iterator_tag operator++(int); + + bool operator==(bad_iterator_tag const&) const = default; +}; +static_assert(!std::forward_iterator); + +struct not_incrementable { + using value_type = int; + using difference_type = std::ptrdiff_t; + using iterator_concept = std::forward_iterator_tag; + + int operator*() const; + + not_incrementable& operator++(); + void operator++(int); + + bool operator==(not_incrementable const&) const = default; +}; +static_assert(!std::forward_iterator); + +struct not_equality_comparable { + using value_type = int; + using difference_type = std::ptrdiff_t; + using iterator_concept = std::forward_iterator_tag; + + int operator*() const; + + not_equality_comparable& operator++(); + not_equality_comparable operator++(int); + + bool operator==(not_equality_comparable const&) const = delete; +}; +static_assert(!std::forward_iterator); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp @@ -0,0 +1 @@ +// Due to the need to check _ITER_CONCEPT, this test is located in `test/libcxx/iterators/iterator.concepts/iterator.concept.forward/subsumption.compile.pass.cpp`. diff --git a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/move.iterators/move.iterator/iterator_concept_conformance.compile.pass.cpp @@ -16,10 +16,11 @@ #include using iterator = std::move_iterator; -static_assert(std::indirectly_readable); + + +static_assert(std::input_iterator); +static_assert(!std::forward_iterator); static_assert(!std::indirectly_writable); static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/reverse.iterators/iterator_concept_conformance.compile.pass.cpp @@ -15,16 +15,28 @@ #include -using iterator = std::reverse_iterator; - -static_assert(std::indirectly_readable); -static_assert(std::indirectly_writable); -static_assert(std::incrementable); -static_assert(std::input_or_output_iterator); -static_assert(std::sentinel_for); -static_assert(std::sized_sentinel_for); -static_assert(std::input_iterator); - -using other_iterator = std::reverse_iterator; -static_assert(std::sentinel_for); -static_assert(!std::sized_sentinel_for); +#include "test_iterators.h" + +template +[[nodiscard]] consteval bool common_reverse_iterator_checks() { + static_assert(std::indirectly_writable); + static_assert(std::sentinel_for); + static_assert(std::sentinel_for>); + static_assert(!std::sized_sentinel_for>); + return true; +} + +using reverse_bidirectional_iterator = std::reverse_iterator>; +static_assert(common_reverse_iterator_checks()); +static_assert(std::forward_iterator); +static_assert(!std::sized_sentinel_for); + +using reverse_random_access_iterator = std::reverse_iterator>; +static_assert(common_reverse_iterator_checks()); +static_assert(std::forward_iterator); +static_assert(std::sized_sentinel_for); + +using reverse_contiguous_iterator = std::reverse_iterator>; +static_assert(common_reverse_iterator_checks()); +static_assert(std::forward_iterator); +static_assert(std::sized_sentinel_for); diff --git a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp --- a/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/istreambuf.iterator/iterator_concept_conformance.compile.pass.cpp @@ -19,11 +19,10 @@ #include using iterator = std::istreambuf_iterator; -static_assert(std::indirectly_readable); + +static_assert(std::input_iterator); +static_assert(!std::forward_iterator); static_assert(!std::indirectly_writable); -static_assert(std::weakly_incrementable); static_assert(!std::incrementable); -static_assert(std::input_or_output_iterator); static_assert(std::sentinel_for); static_assert(!std::sized_sentinel_for); -static_assert(std::input_iterator); diff --git a/libcxx/test/std/ranges/range.refinements/forward_range.compile.pass.cpp b/libcxx/test/std/ranges/range.refinements/forward_range.compile.pass.cpp new file mode 100644 --- /dev/null +++ b/libcxx/test/std/ranges/range.refinements/forward_range.compile.pass.cpp @@ -0,0 +1,41 @@ +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +// UNSUPPORTED: c++03, c++11, c++14, c++17 +// UNSUPPORTED: libcpp-no-concepts +// UNSUPPORTED: gcc-10 +// XFAIL: msvc && clang + +// std::ranges::forward_range; + +#include + +#include "test_iterators.h" +#include "test_range.h" + +namespace stdr = std::ranges; + +template