Iterator concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator primitives | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Algorithm concepts and utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Indirect callable concepts | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Common algorithm requirements | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Utilities | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
| |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Iterator adaptors | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
Defined in header <iterator> | ||
struct default_sentinel_t{}; | (1) | (since C++20) |
inlineconstexpr default_sentinel_t default_sentinel{}; | (2) | (since C++20) |
default_sentinel_t
is an empty class type used to denote the end of a range. It can be used together with iterator types that know the bound of their range (e.g.,std::counted_iterator).default_sentinel
is a constant of typedefault_sentinel_t
.#include <print>#include <regex>#include <string> int main(){conststd::string s="Quick brown fox."; conststd::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(conststd::smatch& match: words)std::println("{}", match.str());}
Output:
Found 3 words:Quickbrownfox.
input iterator that reads fromstd::basic_istream (class template)[edit] | |
input iterator that reads fromstd::basic_streambuf (class template)[edit] | |
(C++20) | iterator adaptor that tracks the distance to the end of the range (class template)[edit] |