32 lines
1.5 KiB
Markdown
32 lines
1.5 KiB
Markdown
[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.4 Concept 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.4 Concept weakly_incrementable [iterator.concept.winc]") I>friend constexpr bool operator==(unreachable_sentinel_t, const I&) noexcept{ return false; }};}
|