diff --git a/libcxx/test/std/ranges/range.adaptors/range.join.view/types.h b/libcxx/test/std/ranges/range.adaptors/range.join.view/types.h --- a/libcxx/test/std/ranges/range.adaptors/range.join.view/types.h +++ b/libcxx/test/std/ranges/range.adaptors/range.join.view/types.h @@ -196,29 +196,6 @@ } }; -// an `input_iterator` that can be used in a `common_range` -template -struct common_input_iterator { - Base it_; - - using value_type = std::iter_value_t; - using difference_type = std::intptr_t; - using iterator_concept = std::input_iterator_tag; - - constexpr common_input_iterator() = default; - constexpr explicit common_input_iterator(Base it) : it_(it) {} - - constexpr common_input_iterator& operator++() { - ++it_; - return *this; - } - constexpr void operator++(int) { ++it_; } - - constexpr std::iter_reference_t operator*() const { return *it_; } - - friend constexpr bool operator==(common_input_iterator const&, common_input_iterator const&) = default; -}; - using InputCommonInner = BufferView>; static_assert(std::ranges::input_range); static_assert(!std::ranges::forward_range); diff --git a/libcxx/test/std/ranges/range.adaptors/range.zip/types.h b/libcxx/test/std/ranges/range.adaptors/range.zip/types.h --- a/libcxx/test/std/ranges/range.adaptors/range.zip/types.h +++ b/libcxx/test/std/ranges/range.adaptors/range.zip/types.h @@ -302,29 +302,7 @@ static_assert(!std::ranges::common_range); static_assert(std::ranges::sized_range); -template -struct common_input_iterator { - Base it_; - - using value_type = int; - using difference_type = std::intptr_t; - using iterator_concept = std::input_iterator_tag; - - constexpr common_input_iterator() = default; - constexpr explicit common_input_iterator(Base it) : it_(it) {} - - constexpr common_input_iterator& operator++() { - ++it_; - return *this; - } - constexpr void operator++(int) { ++it_; } - - constexpr int& operator*() const { return *it_; } - - friend constexpr bool operator==(common_input_iterator const&, common_input_iterator const&) = default; -}; - -using InputCommonView = BasicView>; +using InputCommonView = BasicView>; static_assert(std::ranges::input_range); static_assert(!std::ranges::forward_range); static_assert(std::ranges::common_range); @@ -337,7 +315,7 @@ static_assert(std::ranges::common_range); LIBCPP_STATIC_ASSERT(!std::ranges::__simple_view); -using InputNonCommonView = BasicView, sentinel_wrapper>>; +using InputNonCommonView = BasicView, sentinel_wrapper>>; static_assert(std::ranges::input_range); static_assert(!std::ranges::forward_range); static_assert(!std::ranges::common_range); diff --git a/libcxx/test/support/test_iterators.h b/libcxx/test/support/test_iterators.h --- a/libcxx/test/support/test_iterators.h +++ b/libcxx/test/support/test_iterators.h @@ -697,6 +697,33 @@ static_assert(std::output_iterator, int>); +# if TEST_STD_VER > 17 + +// An `input_iterator` that can be used in a `std::ranges::common_range` +template +struct common_input_iterator { + Base it_; + + using value_type = std::iter_value_t; + using difference_type = std::intptr_t; + using iterator_concept = std::input_iterator_tag; + + constexpr common_input_iterator() = default; + constexpr explicit common_input_iterator(Base it) : it_(it) {} + + constexpr common_input_iterator& operator++() { + ++it_; + return *this; + } + constexpr void operator++(int) { ++it_; } + + constexpr std::iter_reference_t operator*() const { return *it_; } + + friend constexpr bool operator==(common_input_iterator const&, common_input_iterator const&) = default; +}; + +# endif // TEST_STD_VER > 17 + // Iterator adaptor that counts the number of times the iterator has had a successor/predecessor // operation called. Has two recorders: // * `stride_count`, which records the total number of calls to an op++, op--, op+=, or op-=.