std:: default_sentinel_t, std:: default_sentinel
From cppreference.net
C++
Iterator library
| Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
定义于头文件
<iterator>
|
||
|
struct
default_sentinel_t
{
}
;
|
(1) | (C++20 起) |
|
inline
constexpr
default_sentinel_t default_sentinel
{
}
;
|
(2) | (C++20 起) |
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)
|
跟踪到范围末尾距离的迭代器适配器
(类模板) |