Files
2025-10-25 03:02:53 +03:00

32 lines
1.5 KiB
Markdown
Raw Permalink Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[unreachable.sentinel]
# 24 Iterators library [[iterators]](./#iterators)
## 24.5 Iterator adaptors [[predef.iterators]](predef.iterators#unreachable.sentinel)
### 24.5.8 Unreachable sentinel [unreachable.sentinel]
[1](#1)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6449)
Class unreachable_sentinel_t can be used with
any [weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4Concept weakly_­incrementable[iterator.concept.winc]") type
to denote the “upper bound” of an unbounded interval[.](#1.sentence-1)
[2](#2)
[#](http://github.com/Eelis/draft/tree/9adde4bc1c62ec234483e63ea3b70a59724c745a/source/iterators.tex#L6454)
[*Example [1](#example-1)*: char* p;// set p to point to a character buffer containing newlineschar* nl = find(p, unreachable_sentinel, '\n');
Provided a newline character really exists in the buffer, the use ofunreachable_sentinel above potentially makes the call to find more
efficient since the loop test against the sentinel does not require a
conditional branch[.](#2.sentence-1)
— *end example*]
[🔗](#lib:operator==,unreachable_sentinel_t)
namespace std {struct unreachable_sentinel_t {template<[weakly_incrementable](iterator.concept.winc#concept:weakly_incrementable "24.3.4.4Concept weakly_­incrementable[iterator.concept.winc]") I>friend constexpr bool operator==(unreachable_sentinel_t, const I&) noexcept{ return false; }};}