GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing cpprefjp.github.io — std::ranges::split_view - cpprefjp C++日本語リファレンス class template <ranges> std::ranges::split_view(C++20)概要指定した区切り文字(デリミタ)によって、入力文字範囲の分割を行うRangeアダプタ。
入力範囲 Rangeコンセプト(
|
| borrowed | sized | output | input | forward | bidirectional | random_access | contiguous | common | viewable | view |
|---|---|---|---|---|---|---|---|---|---|---|
| ○ | ○ | (1) | ○ | ○ |
Vがcommon_rangeのときsplit_viewの要素である、切り出した部分文字列を示す各部分Range)| borrowed | sized | output | input | forward | bidirectional | random_access | contiguous | common | viewable | view |
|---|---|---|---|---|---|---|---|---|---|---|
| ○ | ※ | ※ | ○ | ○ | ※ | ※ | ※ | ※ | ○ | ○ |
Vに従うV、Patternがviewかつforward_rangeVのイテレータとPatternのイテレータが等値比較可能であるviews::split(E, F)の効果はsplit_view(E, F)と等しい。| 名前 | 説明 | 対応バージョン |
|---|---|---|
(constructor) |
コンストラクタ | C++20 |
base |
Vの参照を取得する |
C++20 |
begin |
先頭を指すイテレータを取得する | C++20 |
end |
番兵を取得する | C++20 |
| 名前 | 説明 | 対応バージョン |
|---|---|---|
empty |
Rangeが空かどうかを判定する | C++20 |
operator bool |
Rangeが空でないかどうかを判定する | C++20 |
front |
先頭要素への参照を取得する | C++20 |
cbegin |
定数イテレータを取得する | C++23 |
cend |
定数イテレータ(番兵)を取得する | C++23 |
| 名前 | 説明 | 対応バージョン |
|---|---|---|
(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