brintos

brintos / llvm-project-archived public Read only

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