From Jason Turner

[istream.sentry]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpfmytc0mo/{from.md → to.md} +74 -0
tmp/tmpfmytc0mo/{from.md → to.md} RENAMED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ##### Class `basic_istream::sentry` <a id="istream.sentry">[[istream.sentry]]</a>
2
+
3
+ ``` cpp
4
+ namespace std {
5
+ template<class charT, class traits = char_traits<charT>>
6
+ class basic_istream<charT, traits>::sentry {
7
+ bool ok_; // exposition only
8
+ public:
9
+ explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
10
+ ~sentry();
11
+ explicit operator bool() const { return ok_; }
12
+ sentry(const sentry&) = delete;
13
+ sentry& operator=(const sentry&) = delete;
14
+ };
15
+ }
16
+ ```
17
+
18
+ The class `sentry` defines a class that is responsible for doing
19
+ exception safe prefix and suffix operations.
20
+
21
+ ``` cpp
22
+ explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false);
23
+ ```
24
+
25
+ *Effects:* If `is.good()` is `false`, calls `is.setstate(failbit)`.
26
+ Otherwise, prepares for formatted or unformatted input. First, if
27
+ `is.tie()` is not a null pointer, the function calls `is.tie()->flush()`
28
+ to synchronize the output sequence with any associated external C
29
+ stream. Except that this call can be suppressed if the put area of
30
+ `is.tie()` is empty. Further an implementation is allowed to defer the
31
+ call to `flush` until a call of `is.rdbuf()->underflow()` occurs. If no
32
+ such call occurs before the `sentry` object is destroyed, the call to
33
+ `flush` may be eliminated entirely.[^18] If `noskipws` is zero and
34
+ `is.flags() & ios_base::skipws` is nonzero, the function extracts and
35
+ discards each character as long as the next available input character
36
+ `c` is a whitespace character. If `is.rdbuf()->sbumpc()` or
37
+ `is.rdbuf()->sgetc()` returns `traits::eof()`, the function calls
38
+ `setstate(failbit | eofbit)` (which may throw `ios_base::failure`).
39
+
40
+ *Remarks:* The constructor
41
+
42
+ ``` cpp
43
+ explicit sentry(basic_istream<charT, traits>& is, bool noskipws = false)
44
+ ```
45
+
46
+ uses the currently imbued locale in `is`, to determine whether the next
47
+ input character is whitespace or not.
48
+
49
+ To decide if the character `c` is a whitespace character, the
50
+ constructor performs as if it executes the following code fragment:
51
+
52
+ ``` cpp
53
+ const ctype<charT>& ctype = use_facet<ctype<charT>>(is.getloc());
54
+ if (ctype.is(ctype.space, c) != 0)
55
+ // c is a whitespace character.
56
+ ```
57
+
58
+ If, after any preparation is completed, `is.good()` is `true`,
59
+ `ok_ != false` otherwise, `ok_ == false`. During preparation, the
60
+ constructor may call `setstate(failbit)` (which may throw
61
+ `ios_base::failure` [[iostate.flags]]).[^19]
62
+
63
+ ``` cpp
64
+ ~sentry();
65
+ ```
66
+
67
+ *Effects:* None.
68
+
69
+ ``` cpp
70
+ explicit operator bool() const;
71
+ ```
72
+
73
+ *Returns:* `ok_`.
74
+