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-exception 6 // 7 //===----------------------------------------------------------------------===// 8 9 // UNSUPPORTED: c++03, c++11, c++14, c++17 10 11 // Some basic examples of how drop_while_view might be used in the wild. This is a general 12 // collection of sample algorithms and functions that try to mock general usage of 13 // this view. 14 15 #include <algorithm> 16 #include <cassert> 17 #include <ranges> 18 #include <string_view> 19 main(int,char **)20int main(int, char**) { 21 using namespace std::string_view_literals; 22 std::string_view source = " \t \t \t hello there"sv; 23 auto is_invisible = [](const auto x) { return x == ' ' || x == '\t'; }; 24 auto skip_ws = std::views::drop_while(source, is_invisible); 25 assert(std::ranges::equal(skip_ws, "hello there"sv)); 26 27 return 0; 28 } 29