From Jason Turner

[unreachable.sentinel]

Diff to HTML by rtfpessoa

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