std::default_sentinel_t, std::default_sentinel
From cppreference.com
| ヘッダ <iterator> で定義 |
||
| struct default_sentinel_t {}; |
(1) | (C++20以降) |
| inline constexpr default_sentinel_t default_sentinel{}; |
(2) | (C++20以降) |
1)
default_sentinel_t は、範囲の末尾を示すために使用される空のクラス型です。範囲の境界を知っているイテレータ型 (例: std::counted_iterator) と一緒に使用できます。2)
default_sentinel は、default_sentinel_t 型の定数です。[編集] 例
このコードを実行
#include <print> #include <regex> #include <string> int main() { const std::string s = "Quick brown fox."; const std::regex words_regex("[^\\s]+"); const std::ranges::subrange words( std::sregex_iterator(s.begin(), s.end(), words_regex), std::default_sentinel); std::println("Found {} words:", std::ranges::distance(words)); for (const std::smatch& match : words) std::println("{}", match.str()); }
出力
Found 3 words: Quick brown fox.
[編集] 関連項目
| std::basic_istream から読み取る入力イテレータ (クラステンプレート) | |
| std::basic_streambuf から読み取る入力イテレータ (クラステンプレート) | |
| (C++20) |
範囲の終端までの距離を追跡するイテレータアダプタ (クラステンプレート) |