From c05d1eed35f5284c1eafc86e26cf0a304fb0a35b Mon Sep 17 00:00:00 2001 From: Christopher Di Bella Date: Sun, 11 Apr 2021 19:04:52 +0000 Subject: [PATCH] [libcxx][iterator][ranges] adds `input_iterator` and `input_range` Implements parts of: * P0896R4 The One Ranges Proposal` Depends on D100269. Differential Revision: https://reviews.llvm.org/D100271 --- libcxx/include/__iterator/concepts.h | 8 ++ libcxx/include/__ranges/concepts.h | 3 + libcxx/include/iterator | 4 + libcxx/include/ranges | 3 + .../subsumption.compile.pass.cpp | 35 ++++++ .../iterator_concept_conformance.compile.pass.cpp | 1 + .../map/range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../set/range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 2 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 2 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 4 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 4 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 4 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 4 + .../range_concept_conformance.compile.pass.cpp | 2 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 2 + .../range_concept_conformance.compile.pass.cpp | 4 + .../range_concept_conformance.compile.pass.cpp | 2 + .../input_iterator.compile.pass.cpp | 125 +++++++++++++++++++++ .../subsumption.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range.refinements/input_range.compile.pass.cpp | 45 ++++++++ .../range.refinements/subsumption.compile.pass.cpp | 40 +++++++ .../iterator_concept_conformance.compile.pass.cpp | 1 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + .../range_concept_conformance.compile.pass.cpp | 2 + .../iterator_concept_conformance.compile.pass.cpp | 1 + libcxx/test/support/test_iterators.h | 37 ++++++ libcxx/test/support/test_macros.h | 4 + libcxx/test/support/test_range.h | 2 +- 61 files changed, 392 insertions(+), 1 deletion(-) create mode 100644 libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp create mode 100644 libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/input_iterator.compile.pass.cpp create mode 100644 libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp create mode 100644 libcxx/test/std/ranges/range.refinements/input_range.compile.pass.cpp create mode 100644 libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp diff --git a/libcxx/include/__iterator/concepts.h b/libcxx/include/__iterator/concepts.h index 445a88f..df94cf6 100644 --- a/libcxx/include/__iterator/concepts.h +++ b/libcxx/include/__iterator/concepts.h @@ -111,6 +111,14 @@ concept sized_sentinel_for = { __i - __s } -> same_as >; }; +// [iterator.concept.input] +template +concept input_iterator = + input_or_output_iterator<_Ip> && + indirectly_readable<_Ip> && + requires { typename _ITER_CONCEPT<_Ip>; } && + derived_from<_ITER_CONCEPT<_Ip>, input_iterator_tag>; + // clang-format on #endif // !defined(_LIBCPP_HAS_NO_RANGES) diff --git a/libcxx/include/__ranges/concepts.h b/libcxx/include/__ranges/concepts.h index aeed55c..bccb8f6 100644 --- a/libcxx/include/__ranges/concepts.h +++ b/libcxx/include/__ranges/concepts.h @@ -52,6 +52,9 @@ namespace ranges { // [range.refinements], other range refinements template + concept input_range = range<_Tp> && input_iterator >; + + template concept common_range = range<_Tp> && same_as, sentinel_t<_Tp> >; } // namespace ranges diff --git a/libcxx/include/iterator b/libcxx/include/iterator index 5be87e1..d759eae 100644 --- a/libcxx/include/iterator +++ b/libcxx/include/iterator @@ -75,6 +75,10 @@ template template concept sized_sentinel_for = see below; +// [iterator.concept.input], concept input_iterator +template + concept input_iterator = see below; // since C++20 + template struct iterator diff --git a/libcxx/include/ranges b/libcxx/include/ranges index a4eda8d..ca9f648 100644 --- a/libcxx/include/ranges +++ b/libcxx/include/ranges @@ -48,6 +48,9 @@ namespace std::ranges { using range_rvalue_reference_t = iter_rvalue_reference_t>; // [range.refinements], other range refinements + template + concept input_range = see below; + template concept common_range = see below; } diff --git a/libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp b/libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp new file mode 100644 index 0000000..73520d9 --- /dev/null +++ b/libcxx/test/libcxx/iterators/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp @@ -0,0 +1,35 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// template +// concept input_iterator; + +#include + +#include + +// clang-format off +template +requires std::indirectly_readable && + std::derived_from, std::input_iterator_tag> +[[nodiscard]] constexpr bool check_subsumption() { + return false; +} + +template +[[nodiscard]] constexpr bool check_subsumption() { + return true; +} +// clang-format on + +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 index c205496..82fd0fd 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); 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 index 4918db1..e778d81 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index 18b5f79..d020d7d 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); 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 index 9443d3f..d0c0e38 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index 62f287d..0f86ddf 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); 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 index ae1745d..c6a2e13 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index f702f3d..bf62926 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); diff --git a/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp index 8ba25cb..7e0fdf6 100644 --- a/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/containers/associative/set/range_concept_conformance.compile.pass.cpp @@ -23,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); 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 index 958864b..58ac42d 100644 --- 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 @@ -47,3 +47,4 @@ 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::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 index a44354d..f2762d4 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index c40267d..4de9eb9 100644 --- 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 @@ -48,3 +48,4 @@ 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::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 index 50e94f7..c9bdb9e 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index 88a5d60..c00151f9 100644 --- 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 @@ -29,6 +29,7 @@ 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::indirectly_writable); @@ -38,3 +39,4 @@ 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 index 32bc9fa..c412813b 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index d468744..a1c0885 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -48,3 +49,4 @@ 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::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 index b958ce6..f567d2a 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index dc06fff..1c1d95b 100644 --- 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 @@ -48,3 +48,4 @@ 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::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 index 8127962..7647ab5 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index a0ba9b2..eca4830 100644 --- 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 @@ -48,3 +48,4 @@ 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::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 index 4c807fe..e384a44 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index 343d296..e694881 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -48,6 +49,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -61,6 +63,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -74,3 +77,4 @@ 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::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 index c5abbae..acbdcc9 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index c4580f2..d0c61cf 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -48,6 +49,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -61,6 +63,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -74,3 +77,4 @@ 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::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 index 9de4684..98b6a07 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index 4da0711..c9990e3 100644 --- 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 @@ -35,6 +35,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -48,6 +49,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -61,6 +63,7 @@ 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::input_iterator); static_assert(std::indirectly_readable); static_assert(!std::indirectly_writable); @@ -74,3 +77,4 @@ 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::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 index 45b7a66..128aa00 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index e731e8b..607f992 100644 --- 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 @@ -31,6 +31,7 @@ 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::indirectly_readable); static_assert(!std::indirectly_writable); @@ -38,6 +39,7 @@ static_assert(std::incrementable); static_assert(std::sentinel_for); static_assert(!std::sentinel_for); static_assert(!std::sentinel_for); +static_assert(std::input_iterator); static_assert(std::indirectly_readable); static_assert(std::incrementable); @@ -46,6 +48,7 @@ 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::indirectly_readable); static_assert(!std::indirectly_writable); @@ -55,3 +58,4 @@ 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); 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 index 4c84bbf..d266fdd 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index 696ee6a..cb26ed6 100644 --- 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,6 +23,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, range::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_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 index ba500b7..0c6aa7d 100644 --- 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 @@ -29,3 +29,4 @@ 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 index af1ce0f..c142915 100644 --- 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 @@ -26,6 +26,7 @@ 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::indirectly_writable); @@ -34,3 +35,4 @@ 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.directory_iterator/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/input.output/filesystems/class.directory_iterator/range_concept_conformance.compile.pass.cpp index 27e96a7..8b80681 100644 --- a/libcxx/test/std/input.output/filesystems/class.directory_iterator/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/input.output/filesystems/class.directory_iterator/range_concept_conformance.compile.pass.cpp @@ -22,12 +22,16 @@ namespace stdr = std::ranges; static_assert(std::same_as, fs::directory_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, fs::directory_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, fs::recursive_directory_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, fs::recursive_directory_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); 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 index 163130b..9db60e4 100644 --- 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,6 +22,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, fs::path::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, fs::path::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/input_iterator.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/input_iterator.compile.pass.cpp new file mode 100644 index 0000000..59c64f4 --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/input_iterator.compile.pass.cpp @@ -0,0 +1,125 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// template +// concept input_iterator; + +#include + +#include "test_iterators.h" + +static_assert(std::input_iterator >); +static_assert(std::input_iterator >); + +struct no_explicit_iter_concept { + using value_type = int; + using difference_type = std::ptrdiff_t; + + no_explicit_iter_concept() = default; + + no_explicit_iter_concept(no_explicit_iter_concept&&) = default; + no_explicit_iter_concept& operator=(no_explicit_iter_concept&&) = default; + + no_explicit_iter_concept(no_explicit_iter_concept const&) = delete; + no_explicit_iter_concept& operator=(no_explicit_iter_concept const&) = delete; + + value_type operator*() const; + + no_explicit_iter_concept& operator++(); + void operator++(int); +}; +// ITER-CONCEPT is `random_access_iterator_tag` >:( +static_assert(std::input_iterator); + +static_assert(std::input_iterator); +static_assert(std::input_iterator); +static_assert(std::input_iterator); +static_assert(std::input_iterator); + +struct not_weakly_incrementable { + using difference_type = std::ptrdiff_t; + using iterator_concept = std::input_iterator_tag; + + not_weakly_incrementable() = default; + + not_weakly_incrementable(not_weakly_incrementable&&) = default; + not_weakly_incrementable& operator=(not_weakly_incrementable&&) = default; + + not_weakly_incrementable(not_weakly_incrementable const&) = delete; + not_weakly_incrementable& operator=(not_weakly_incrementable const&) = delete; + + int operator*() const; + + not_weakly_incrementable& operator++(); +}; +static_assert(!std::input_or_output_iterator && + !std::input_iterator); + +struct not_indirectly_readable { + using difference_type = std::ptrdiff_t; + using iterator_concept = std::input_iterator_tag; + + not_indirectly_readable() = default; + + not_indirectly_readable(not_indirectly_readable&&) = default; + not_indirectly_readable& operator=(not_indirectly_readable&&) = default; + + not_indirectly_readable(not_indirectly_readable const&) = delete; + not_indirectly_readable& operator=(not_indirectly_readable const&) = delete; + + int operator*() const; + + not_indirectly_readable& operator++(); + void operator++(int); +}; +static_assert(!std::indirectly_readable && !std::input_iterator); + +struct bad_iterator_category { + using value_type = int; + using difference_type = std::ptrdiff_t; + using iterator_category = void; + + bad_iterator_category() = default; + + bad_iterator_category(bad_iterator_category&&) = default; + bad_iterator_category& operator=(bad_iterator_category&&) = default; + + bad_iterator_category(bad_iterator_category const&) = delete; + bad_iterator_category& operator=(bad_iterator_category const&) = delete; + + value_type operator*() const; + + bad_iterator_category& operator++(); + void operator++(int); +}; +static_assert(!std::input_iterator); + +struct bad_iterator_concept { + using value_type = int; + using difference_type = std::ptrdiff_t; + using iterator_concept = void*; + + bad_iterator_concept() = default; + + bad_iterator_concept(bad_iterator_concept&&) = default; + bad_iterator_concept& operator=(bad_iterator_concept&&) = default; + + bad_iterator_concept(bad_iterator_concept const&) = delete; + bad_iterator_concept& operator=(bad_iterator_concept const&) = delete; + + value_type operator*() const; + + bad_iterator_concept& operator++(); + void operator++(int); +}; +static_assert(!std::input_iterator); diff --git a/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/subsumption.compile.pass.cpp new file mode 100644 index 0000000..3a18b8a --- /dev/null +++ b/libcxx/test/std/iterators/iterator.requirements/iterator.concepts/iterator.concept.input/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.input/subsumption.compile.pass.cpp`. diff --git a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp index 5bc7b71..c6cd99e 100644 --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/back.insert.iterator/iterator_concept_conformance.compile.pass.cpp @@ -24,3 +24,4 @@ static_assert(!std::weakly_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/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp index 413c31d..ada8563 100644 --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/front.insert.iterator/iterator_concept_conformance.compile.pass.cpp @@ -24,3 +24,4 @@ static_assert(!std::weakly_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/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp index 9376157..e7dc465 100644 --- a/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/predef.iterators/insert.iterators/insert.iterator/iterator_concept_conformance.compile.pass.cpp @@ -23,3 +23,4 @@ static_assert(std::indirectly_writable); static_assert(!std::weakly_incrementable); static_assert(!std::input_or_output_iterator); static_assert(!std::sentinel_for); +static_assert(!std::input_iterator); 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 index 485df7c..7d6325c 100644 --- 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 @@ -22,3 +22,4 @@ 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 index f5b9082..4df9058 100644 --- 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 @@ -23,6 +23,7 @@ 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); diff --git a/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp index 6db8603..514ba41 100644 --- a/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/istream.iterator/iterator_concept_conformance.compile.pass.cpp @@ -24,3 +24,4 @@ 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/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 index 2cbe4e0..70da029 100644 --- 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 @@ -26,3 +26,4 @@ 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/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp index efe5a17..c0fe917 100644 --- a/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/ostream.iterator/iterator_concept_conformance.compile.pass.cpp @@ -24,3 +24,4 @@ static_assert(!std::weakly_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/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp index fc28ce9..86abbc0 100644 --- a/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/iterators/stream.iterators/ostreambuf.iterator/iterator_concept_conformance.compile.pass.cpp @@ -25,3 +25,4 @@ static_assert(!std::weakly_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/input_range.compile.pass.cpp b/libcxx/test/std/ranges/range.refinements/input_range.compile.pass.cpp new file mode 100644 index 0000000..8ca8885 --- /dev/null +++ b/libcxx/test/std/ranges/range.refinements/input_range.compile.pass.cpp @@ -0,0 +1,45 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// template +// concept input_range; + +#include + +#include "test_range.h" + +namespace stdr = std::ranges; + +static_assert(stdr::input_range >); +static_assert(stdr::input_range const>); + +static_assert(stdr::input_range >); +static_assert(stdr::input_range const>); + +static_assert(stdr::input_range >); +static_assert(stdr::input_range >); + +static_assert(!stdr::input_range const>); +static_assert(!stdr::input_range const>); + +static_assert(stdr::input_range >); +static_assert(!stdr::input_range >); + +static_assert(stdr::input_range const>); +static_assert(!stdr::input_range const>); + +static_assert(stdr::input_range >); +static_assert(!stdr::input_range >); + +static_assert(!stdr::input_range const>); +static_assert(!stdr::input_range const>); diff --git a/libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp b/libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp new file mode 100644 index 0000000..681146b --- /dev/null +++ b/libcxx/test/std/ranges/range.refinements/subsumption.compile.pass.cpp @@ -0,0 +1,40 @@ +//===----------------------------------------------------------------------===// +// +// 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 + +// template +// concept input_iterator; + +#include + +#include + +struct range { + int* begin(); + int* end(); +}; + +// clang-format off +template +requires std::input_iterator > +[[nodiscard]] constexpr bool check_input_range_subsumption() { + return false; +} + +template +requires true +[[nodiscard]] constexpr bool check_input_range_subsumption() { + return true; +} +// clang-format on + +static_assert(check_input_range_subsumption()); diff --git a/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp index 897e744..19caf08e 100644 --- a/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/re/re.iter/re.regiter/iterator_concept_conformance.compile.pass.cpp @@ -23,3 +23,4 @@ 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/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp index f94382f..17a49fe 100644 --- a/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/re/re.iter/re.tokiter/iterator_concept_conformance.compile.pass.cpp @@ -23,3 +23,4 @@ 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/re/re.results/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/re/re.results/range_concept_conformance.compile.pass.cpp index 10f48a9..22eb3b4 100644 --- a/libcxx/test/std/re/re.results/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/re/re.results/range_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, std::cmatch::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, std::cmatch::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); diff --git a/libcxx/test/std/strings/basic.string/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/basic.string/range_concept_conformance.compile.pass.cpp index c352dda..2d07397 100644 --- a/libcxx/test/std/strings/basic.string/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/basic.string/range_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, std::string::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, std::string::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); diff --git a/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp index 616fdf6..cae5720 100644 --- a/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/basic.string/string.iterators/iterator_concept_conformance.compile.pass.cpp @@ -47,3 +47,4 @@ 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::input_iterator); diff --git a/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp index 595a12f..7fbafdc 100644 --- a/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/string.view/range_concept_conformance.compile.pass.cpp @@ -22,6 +22,8 @@ namespace stdr = std::ranges; static_assert(std::same_as, std::string_view::iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); static_assert(std::same_as, std::string_view::const_iterator>); static_assert(stdr::common_range); +static_assert(stdr::input_range); diff --git a/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp b/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp index 409f197..adb21bc 100644 --- a/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp +++ b/libcxx/test/std/strings/string.view/string.view.iterators/iterator_concept_conformance.compile.pass.cpp @@ -47,3 +47,4 @@ 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::input_iterator); diff --git a/libcxx/test/support/test_iterators.h b/libcxx/test/support/test_iterators.h index cc5d018..cea849f 100644 --- a/libcxx/test/support/test_iterators.h +++ b/libcxx/test/support/test_iterators.h @@ -632,6 +632,43 @@ template bool operator!= (const NonThrowingIterator& a, const NonThrowingIterator& b) TEST_NOEXCEPT { return !a.operator==(b); } +#ifdef TEST_SUPPORTS_RANGES + +template +struct cpp20_input_iterator { + using value_type = std::iter_value_t; + using difference_type = std::iter_difference_t; + using iterator_concept = std::input_iterator_tag; + + cpp20_input_iterator() = default; + + cpp20_input_iterator(cpp20_input_iterator&&) = default; + cpp20_input_iterator& operator=(cpp20_input_iterator&&) = default; + + cpp20_input_iterator(cpp20_input_iterator const&) = delete; + cpp20_input_iterator& operator=(cpp20_input_iterator const&) = delete; + + explicit constexpr cpp20_input_iterator(I base) : base_(std::move(base)) {} + + constexpr decltype(auto) operator*() const { return *base_; } + + cpp20_input_iterator& operator++() { + ++base_; + return *this; + } + + void operator++(int) { ++base_; } + + [[nodiscard]] I const& base() const& { return base_; } + + [[nodiscard]] I base() && { return std::move(base_); } + +private: + I base_ = I(); +}; + +#endif // TEST_STD_VER > 17 && defined(__cpp_lib_concepts) + #undef DELETE_FUNCTION #endif // ITERATORS_H diff --git a/libcxx/test/support/test_macros.h b/libcxx/test/support/test_macros.h index 82a8511..c39e79b 100644 --- a/libcxx/test/support/test_macros.h +++ b/libcxx/test/support/test_macros.h @@ -312,6 +312,10 @@ #define LIBCPP_ONLY(...) ((void)0) #endif +#if !defined(_LIBCPP_HAS_NO_RANGES) +#define TEST_SUPPORTS_RANGES +#endif + #define TEST_IGNORE_NODISCARD (void) namespace test_macros_detail { diff --git a/libcxx/test/support/test_range.h b/libcxx/test/support/test_range.h index 3e9c94a..1b13dea 100644 --- a/libcxx/test/support/test_range.h +++ b/libcxx/test/support/test_range.h @@ -18,7 +18,7 @@ #endif struct sentinel { - bool operator==(std::input_or_output_iterator auto) const; + bool operator==(std::input_or_output_iterator auto const&) const; }; // clang-format off -- 2.7.4