Namespaces
Variants

std:: default_sentinel_t, std:: default_sentinel

From cppreference.net
Iterator library
Iterator concepts
Iterator primitives
Algorithm concepts and utilities
Indirect callable concepts
Common algorithm requirements
(C++20)
(C++20)
(C++20)
Utilities
(C++20)
Iterator adaptors
default_sentinel_t default_sentinel
(C++20) (C++20)
Range access
(C++11) (C++14)
(C++14) (C++14)
(C++11) (C++14)
(C++14) (C++14)
(C++17) (C++20)
(C++17)
(C++17)
헤더에 정의됨 <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 에서 읽어들이는 입력 반복자
(클래스 템플릿)
범위의 끝까지 거리를 추적하는 반복자 어댑터
(클래스 템플릿)