std::defaul...ult_sentinel(3)
π NAME π
okay bestie, welcome to the std::defaul...ult_sentinel(3) page β from the manual named C++ Standard Libary (yes, spelled exactly like that in the manual name, and we are not fixing it, periodt). Todayβs main characters are std::default_sentinel_t and std::default_sentinel, and they are absolutely iconic in a quiet, empty-class kinda way π
.
std::default_sentinel_t,std::default_sentinelβstd::default_sentinel_t,std::default_sentinel
πΈ Synopsis πΈ
Defined in header <iterator>.
struct default_sentinel_t {}; (1) (since C++20)
inline constexpr default_sentinel_t default_sentinel{}; (2) (since C++20)
default_sentinel_tis 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). π¦default_sentinelis a constant of typedefault_sentinel_t. β¨
π Example π
// Run this code
#include <algorithm>
#include <iostream>
#include <iterator>
#include <list>
int main()
{
std::list<int> l{3, 1, 4, 1, 5, 9, 2, 6};
std::ranges::copy(std::counted_iterator(std::begin(l), 4),
std::default_sentinel, std::ostream_iterator<int>{std::cout, " "});
std::cout << '\n';
}
π Output π
3 1 4 1
π₯ See also π₯
istream_iteratorβ input iterator that reads fromstd::basic_istream(class template) πistreambuf_iteratorβ input iterator that reads fromstd::basic_streambuf(class template) πcounted_iterator(C++20) β iterator adaptor that tracks the distance to the end of the range (class template) π«Ά
k bye bestie π this cutie came from http://cppreference.com, dated 2024.06.10, and the page is std::defaul...ult_sentinel(3). slay and stay sentinel-y π
π¦ where this page comes from
- nixpkgs unstable: stdman 2024.07.05
- opensuse-leap 16.0: stdman 2024.07.05-bp160.1.9 Β· MIT
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms