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 | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Definiert im Header
<iterator>
|
||
|
struct
default_sentinel_t
{
}
;
|
(1) | (seit C++20) |
|
inline
constexpr
default_sentinel_t default_sentinel
{
}
;
|
(2) | (seit C++20) |
1)
default_sentinel_t
ist ein leerer Klassentyp, der verwendet wird, um das Ende eines Bereichs zu kennzeichnen. Es kann zusammen mit Iteratortypen verwendet werden, die die Grenze ihres Bereichs kennen (z.B.
std::counted_iterator
).
2)
default_sentinel
ist eine Konstante vom Typ
default_sentinel_t
.
Beispiel
Diesen Code ausführen
#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()); }
Ausgabe:
Found 3 words: Quick brown fox.
Siehe auch
|
Eingabe-Iterator, der aus
std::basic_istream
liest
(Klassentemplate) |
|
|
Eingabe-Iterator, der aus
std::basic_streambuf
liest
(Klassentemplate) |
|
|
(C++20)
|
Iterator-Adapter, der den Abstand zum Ende des Bereichs verfolgt
(Klassentemplate) |