From Jason Turner

[unreachable.sentinels]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmppm54aunq/{from.md → to.md} +0 -33
tmp/tmppm54aunq/{from.md → to.md} RENAMED
@@ -1,33 +0,0 @@
1
- ### Unreachable sentinel <a id="unreachable.sentinels">[[unreachable.sentinels]]</a>
2
-
3
- #### Class `unreachable_sentinel_t` <a id="unreachable.sentinel">[[unreachable.sentinel]]</a>
4
-
5
- Class `unreachable_sentinel_t` can be used with any
6
- `weakly_incrementable` type to denote the “upper bound” of an unbounded
7
- interval.
8
-
9
- [*Example 1*:
10
-
11
- ``` cpp
12
- char* p;
13
- // set p to point to a character buffer containing newlines
14
- char* nl = find(p, unreachable_sentinel, '\n');
15
- ```
16
-
17
- Provided a newline character really exists in the buffer, the use of
18
- `unreachable_sentinel` above potentially makes the call to `find` more
19
- efficient since the loop test against the sentinel does not require a
20
- conditional branch.
21
-
22
- — *end example*]
23
-
24
- ``` cpp
25
- namespace std {
26
- struct unreachable_sentinel_t {
27
- template<weakly_incrementable I>
28
- friend constexpr bool operator==(unreachable_sentinel_t, const I&) noexcept
29
- { return false; }
30
- };
31
- }
32
- ```
33
-