1*a2c6a119SHui Xie //===----------------------------------------------------------------------===//
2*a2c6a119SHui Xie //
3*a2c6a119SHui Xie // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4*a2c6a119SHui Xie // See https://llvm.org/LICENSE.txt for license information.
5*a2c6a119SHui Xie // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6*a2c6a119SHui Xie //
7*a2c6a119SHui Xie //===----------------------------------------------------------------------===//
8*a2c6a119SHui Xie
9*a2c6a119SHui Xie // UNSUPPORTED: c++03, c++11, c++14, c++17
10*a2c6a119SHui Xie
11*a2c6a119SHui Xie // Some basic examples of how take_while_view might be used in the wild. This is a general
12*a2c6a119SHui Xie // collection of sample algorithms and functions that try to mock general usage of
13*a2c6a119SHui Xie // this view.
14*a2c6a119SHui Xie
15*a2c6a119SHui Xie #include <algorithm>
16*a2c6a119SHui Xie #include <cassert>
17*a2c6a119SHui Xie #include <ranges>
18*a2c6a119SHui Xie
main(int,char **)19*a2c6a119SHui Xie int main(int, char**) {
20*a2c6a119SHui Xie {
21*a2c6a119SHui Xie auto input = {0, 1, 2, 3, 4, 5, 6, 5, 4, 3, 2, 1, 0};
22*a2c6a119SHui Xie auto small = [](const auto x) noexcept { return x < 5; };
23*a2c6a119SHui Xie auto small_ints = input | std::views::take_while(small);
24*a2c6a119SHui Xie auto expected = {0, 1, 2, 3, 4};
25*a2c6a119SHui Xie assert(std::ranges::equal(small_ints, expected));
26*a2c6a119SHui Xie }
27*a2c6a119SHui Xie return 0;
28*a2c6a119SHui Xie }
29