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_istream
(クラステンプレート)
std::basic_streambufから読み込む入力イテレータ std::basic_streambuf
(クラステンプレート)
範囲の終端までの距離を追跡するイテレータアダプタ
(クラステンプレート)