std::default_sentinel_t, std::default_sentinel
From cppreference.com
 
 
 
 
 
 C++ 
 Feature test macros (C++20)
 Concepts library (C++20)
 Metaprogramming library (C++11)
 Ranges library (C++20)
 Filesystem library (C++17)
 Concurrency support library (C++11)
 Execution control library (C++26)
Iterator library 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
   
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
  
 
 
  
 
 
 
 
 
  
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)
(C++20)(C++20)(C++20)(C++23)(C++20)(C++20)
(deprecated in C++17)
(C++20)
(C++20)
(C++20)(C++20)
  (C++20)
(C++20)
(C++20)
(C++20)
(C++14)
(C++11)
(C++11)
default_sentinel_tdefault_sentinel
(C++20)(C++20)
(C++20)(C++20)
(C++20)
(C++20)
(C++20)
(C++23)
(C++23)
(C++23)
(C++23)
(C++23)
(C++11)(C++14)
(C++14)(C++14)
  Defined in header 
 
 
<iterator> 
 struct default_sentinel_t {};
 (1) 
 (since C++20) 
inline constexpr default_sentinel_t default_sentinel{};
 (2) 
 (since C++20) 
1) 
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 ).2) 
default_sentinel is a constant of type default_sentinel_t.[edit] Example
Run this code
#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()); }
Output:
Found 3 words: Quick brown fox.