std::defaul...ult_sentinel(3)

πŸ“¦ version 2024.07.05, in nixpkgs unstable, opensuse-leap 16.0

πŸ’– 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)
  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. ✨

πŸŽ€ 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 from std::basic_istream (class template) πŸ‘‘
  • istreambuf_iterator β€” input iterator that reads from std::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