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부터) |
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)
|
범위의 끝까지 거리를 추적하는 반복자 어댑터
(클래스 템플릿) |