std::experi...es::Sentinel(3)
π NAME π
std::experimental::ranges::Sentinel β bestie, it's the concept that says "yes, this sentinel type and this iterator type are literally a whole range together" β¨
πΈ Synopsis πΈ
okay so first things first, it lives in this header:
<experimental/ranges/iterator>
and here's the whole vibe, copied exactly because I would never mess with your declarations:
template< class S, class I >
concept bool Sentinel = (ranges TS)
Semiregular<S> && Iterator<I> &&
WeaklyEqualityComparableWith<S, I>;
No cap, that's the entire concept. S is your sentinel, I is your iterator, and they have to be cute together. π«Ά
π¦ DESCRIPTION π¦
So the Sentinel concept specifies the relationship between an Iterator type and a Semiregular type whose values denote a range. That's it. That's the whole job. A semiregular little buddy hanging out at the end of your iterator range, marking where the party stops. π
Let s and i be values of type S and I, respectively, such that [i, s) denotes a range. Then Sentinel<S, I> is satisfied only if these two things hold:
i == sis well-defined. (fr fr, the comparison has to actually make sense, no undefined behaviour shenanigans π)- If
bool(i != s), theniis dereferenceable and[++i, s)denotes a range. (like, if you're not at the sentinel yet, you'd better be pointing at something real, and stepping forward had better keep you inside the range.)
β οΈ the domain-of-== situation β οΈ
bestie, listen to me, this part matters π
The domain of == can change over time. That is not a bug, that's just how it is.
Given an iterator i and sentinel s such that [i, s) denotes a range and i != s, [i, s) is not required to continue to denote a range after incrementing any iterator equal to i.
And because of that: i == s is no longer required to be well-defined after such an increment. π
So yeah β you can't just go incrementing and then assume the comparison still means anything. The concept said what it said. Don't come for it. π
π see you, bestie π
that's the whole page, mwah π β this slay little number came from http://cppreference.com, dated 2024.06.10, and it was brought to you by the manpage formerly known as std::experi...es::Sentinel(3). go forth and iterate responsibly, ily! ππ
π¦ 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