class template
std::ranges::split_view(C++20)
概要
- (1):
forward_range
を要素、または要素のview
からなるパターンをデリミタとして分割し、それぞれの部分Rangeを要素とする新たなRangeとして扱うview
- (2):
split_view
を生成するRangeアダプタオブジェクト
Rangeコンセプト
borrowed |
sized |
output |
input |
forward |
bidirectional |
random_access |
contiguous |
common |
viewable |
view |
|
|
|
○ |
○ |
|
|
|
(1) |
○ |
○ |
Rangeコンセプト (各部分Range)
borrowed |
sized |
output |
input |
forward |
bidirectional |
random_access |
contiguous |
common |
viewable |
view |
○ |
※ |
※ |
○ |
○ |
※ |
※ |
※ |
※ |
○ |
○ |
テンプレートパラメータ制約
効果
- (2): 式
views::split(E, F)
の効果はsplit_view{E, F}
と等しい。
メンバ関数
名前 |
説明 |
対応バージョン |
(constructor) |
コンストラクタ |
C++20 |
base |
V の参照を取得する |
C++20 |
begin |
先頭を指すイテレータを取得する |
C++20 |
end |
番兵を取得する |
C++20 |
継承しているメンバ関数
推論補助
名前 |
説明 |
対応バージョン |
(deduction_guide) |
クラステンプレートの推論補助 |
C++20 |
例
#include <ranges>
#include <string_view>
#include <iostream>
int main() {
using namespace std;
using namespace std::literals;
for (auto sv : "hello, world"sv | views::split(", "sv)) {
std::cout << string_view{sv.begin(), sv.end()} << '\n';
}
}
パターンとしてC文字列を使うとき、ヌル文字を特別扱いしないため注意。
出力
hello
world
バージョン
言語
処理系
参照