Namespaces
Variants

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

From cppreference.net
Ranges library
Range adaptors
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"
                 "substrings: ";
    for (auto split : split_view)
        std::cout << std::quoted(std::string_view{split}) << ' ';
    std::cout << '\n';
}

出力:

base() = "this throw true try typedef typeid"
substrings: "this" "throw" "true" "try" "typedef" "typeid"

不具合報告

以下の動作変更の欠陥報告書は、以前に公開されたC++規格に対して遡及的に適用されました。

DR 適用対象 公開時の動作 正しい動作
LWG 3590 C++20 const & オーバーロードがコピー代入の有効性を追加で要求していた 制約が緩和された

関連項目

基になる(適応された)ビューのコピーを返す
( std::ranges::lazy_split_view<V,Pattern> の公開メンバ関数)