73 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// class std::ranges::lazy_split_view;12 13#include <ranges>14 15#include <cassert>16#include <concepts>17#include <string_view>18#include <type_traits>19#include "types.h"20 21using V = SplitViewForward;22 23static_assert(std::is_base_of_v<std::ranges::view_interface<SplitViewForward>, SplitViewForward>);24 25constexpr bool test() {26 using namespace std::string_view_literals;27 28 // empty()29 {30 {31 std::ranges::lazy_split_view v("abc def", " ");32 assert(!v.empty());33 }34 35 {36 // Note: an empty string literal would still produce a non-empty output because the terminating zero is treated as37 // a separate character; hence the use of `string_view`.38 std::ranges::lazy_split_view v(""sv, "");39 assert(v.empty());40 }41 }42 43 // operator bool()44 {45 {46 std::ranges::lazy_split_view v("abc", "");47 assert(v);48 }49 50 {51 // Note: an empty string literal would still produce a non-empty output because the terminating zero is treated as52 // a separate character; hence the use of `string_view`.53 std::ranges::lazy_split_view v(""sv, "");54 assert(!v);55 }56 }57 58 // front()59 {60 SplitViewForward v("abc", "");61 assert(*(v.front()).begin() == 'a');62 }63 64 return true;65}66 67int main(int, char**) {68 test();69 static_assert(test());70 71 return 0;72}73