名前空間
変種
操作

std::ranges::drop_view<V>::base

From cppreference.com
< cpp‎ | ranges‎ | drop view
 
 
Rangesライブラリ
Rangeアダプタ
 
 
constexpr V base() const& requires std::copy_constructible<V>;
(1) (C++20以降)
constexpr V base() &&;
(2) (C++20以降)

基底ビューのコピーを返します。

1) 元となるビューbase_から結果をコピー構築します。
2) 元となるビューbase_から結果をムーブ構築します。

[編集] 戻り値

元となる(アダプトされた)ビューbase_のコピー。

[編集]

#include <iostream>
#include <ranges>
 
namespace stq {
void println(auto, const auto& v)
{
    for (const auto& e : v)
        std::cout << e << ' ';
    std::cout << '\n';
}
}
 
int main()
{
    static constexpr int a[]{1, 2, 3, 4, 5};
    constexpr auto view = a | std::views::drop(2);
    stq::println("{}", view);
    const auto base = view.base();
    stq::println("{}", base);
}

出力

3 4 5
1 2 3 4 5
English 日本語 中文(简体) 中文(繁體)