名稱空間
變體
操作

std::ranges::lazy_split_view<V,Pattern>::base

來自 cppreference.com
 
 
範圍庫 (Ranges library)
範圍介面卡 (Range adaptors)
 
 
constexpr V base() const& requires std::copy_constructible<V>;
(1) (C++20 起)
constexpr V base() &&;
(2) (C++20 起)

返回底層檢視 base_ 的副本。

1) 從底層檢視 base_ 複製構造結果。
2) 從底層檢視 base_ 移動構造結果。

[編輯] 返回值

底層檢視 base_ 的副本。

[編輯] 示例

#include <iostream>
#include <ranges>
#include <string_view>
 
void print(std::string_view rem, auto const& r, std::string_view post = "\n")
{
    for (std::cout << rem; auto const& e : r)
        std::cout << e;
    std::cout << post;
}
 
int main()
{
    constexpr std::string_view keywords{ "this,..throw,..true,..try,.." };
    constexpr std::string_view pattern{",.."};
    constexpr std::ranges::lazy_split_view lazy_split_view{keywords, pattern};
    print("base() = [", lazy_split_view.base(), "]\n"
          "substrings: ");
    for (auto const& split: lazy_split_view)
        print("[", split, "] ");
}

輸出

base() = [this,..throw,..true,..try,..]
substrings: [this] [throw] [true] [try] []

[編輯] 參閱

返回底層(適配)檢視的副本
(std::ranges::split_view<V,Pattern> 的公開成員函式) [編輯]