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

從 cppreference.com
< cpp‎ | ranges‎ | split view
 
 
範圍庫
範圍適配器
 
 
constexpr V base() const& requires std::copy_constructible<V>;
(1) (C++20 起)
constexpr V base() &&;
(2) (C++20 起)

返回底層視圖 base_ 的副本。

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

目錄

[編輯] 返回值

1) 底層視圖的副本。
2) 一個從底層視圖移動構造的視圖。

[編輯] 示例

#include <iomanip>
#include <iostream>
#include <ranges>
#include <string_view>
 
int main()
{
    constexpr std::string_view keywords{"this throw true try typedef typeid"};
    std::ranges::split_view split_view{keywords, ' '};
    std::cout << "base() = " << std::quoted(split_view.base()) << "\n"
                 "子字符串: ";
    for (auto split : split_view)
        std::cout << std::quoted(std::string_view{split}) << ' ';
    std::cout << '\n';
}

輸出:

base() = "this throw true try typedef typeid"
子字符串: "this" "throw" "true" "try" "typedef" "typeid"

[編輯] 缺陷報告

下列更改行為的缺陷報告追溯地應用於以前出版的 C++ 標準。

缺陷報告 應用於 出版時的行為 正確行為
LWG 3590 C++20 const& 重載額外要求複製賦值有效 放寬約束

[編輯] 參閱

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