From Jason Turner

[istream::sentry]

Diff to HTML by rtfpessoa

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