//===----------------------------------------------------------------------===// // // 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, c++20 // // constexpr value_type operator*() const; #include #include #include #include #include #include #include #include "../types.h" #include "test_iterators.h" template > constexpr void test() { using Underlying = View; using ChunkByView = std::ranges::chunk_by_view; using ChunkByIterator = std::ranges::iterator_t; std::array array{0, 1, 2, 3, -1, 0, 1, 2, -2, 3, 4, 5}; std::array expected{std::array{0, 1, 2, 3}, std::array{-1, 0, 1, 2}, std::array{-2, 3, 4, 5}}; Underlying underlying{Iter{array.data()}, Sent{Iter{array.data() + array.size()}}}; ChunkByView view{underlying, std::ranges::less_equal{}}; size_t idx = 0; for (std::same_as auto iter = view.begin(); iter != view.end(); ++idx, ++iter) { std::same_as auto chunk = *iter; assert(std::ranges::equal(chunk, expected[idx])); } } constexpr bool tests() { // Check iterator-sentinel pair test>(); test>(); test>(); test>(); test(); // Check iterator pair test, forward_iterator>(); test, bidirectional_iterator>(); test, random_access_iterator>(); test, contiguous_iterator>(); test(); return true; } int main(int, char**) { tests(); static_assert(tests()); return 0; }