From Jason Turner

[stringbuf.members]

Diff to HTML by rtfpessoa

Files changed (1) hide show
  1. tmp/tmpz3cq73pc/{from.md → to.md} +126 -31
tmp/tmpz3cq73pc/{from.md → to.md} RENAMED
@@ -1,40 +1,135 @@
1
  #### Member functions <a id="stringbuf.members">[[stringbuf.members]]</a>
2
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
3
  ``` cpp
4
- basic_string<charT, traits, Allocator> str() const;
5
- ```
6
-
7
- *Returns:* A `basic_string` object whose content is equal to the
8
- `basic_stringbuf` underlying character sequence. If the
9
- `basic_stringbuf` was created only in input mode, the resultant
10
- `basic_string` contains the character sequence in the range \[`eback()`,
11
- `egptr()`). If the `basic_stringbuf` was created with
12
- `which & ios_base::out` being nonzero then the resultant `basic_string`
13
- contains the character sequence in the range \[`pbase()`, `high_mark`),
14
- where `high_mark` represents the position one past the highest
15
- initialized character in the buffer. Characters can be initialized by
16
- writing to the stream, by constructing the `basic_stringbuf` with a
17
- `basic_string`, or by calling the `str(basic_string)` member function.
18
- In the case of calling the `str(basic_string)` member function, all
19
- characters initialized prior to the call are now considered
20
- uninitialized (except for those characters re-initialized by the new
21
- `basic_string`). Otherwise the `basic_stringbuf` has been created in
22
- neither input nor output mode and a zero length `basic_string` is
23
- returned.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
  ``` cpp
26
  void str(const basic_string<charT, traits, Allocator>& s);
27
  ```
28
 
29
- *Effects:* Copies the content of `s` into the `basic_stringbuf`
30
- underlying character sequence and initializes the input and output
31
- sequences according to `mode`.
32
-
33
- *Postconditions:* If `mode & ios_base::out` is nonzero, `pbase()` points
34
- to the first underlying character and `epptr()` `>= pbase() + s.size()`
35
- holds; in addition, if `mode & ios_base::ate` is nonzero,
36
- `pptr() == pbase() + s.size()` holds, otherwise `pptr() == pbase()` is
37
- `true`. If `mode & ios_base::in` is nonzero, `eback()` points to the
38
- first underlying character, and both `gptr() == eback()` and
39
- `egptr() == eback() + s.size()` hold.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
 
1
  #### Member functions <a id="stringbuf.members">[[stringbuf.members]]</a>
2
 
3
+ The member functions getting the underlying character sequence all refer
4
+ to a `high_mark` value, where `high_mark` represents the position one
5
+ past the highest initialized character in the buffer. Characters can be
6
+ initialized by writing to the stream, by constructing the
7
+ `basic_stringbuf` passing a `basic_string` argument, or by calling one
8
+ of the `str` member functions passing a `basic_string` as an argument.
9
+ In the latter case, all characters initialized prior to the call are now
10
+ considered uninitialized (except for those characters re-initialized by
11
+ the new `basic_string`).
12
+
13
+ ``` cpp
14
+ void init_buf_ptrs(); // exposition only
15
+ ```
16
+
17
+ *Effects:* Initializes the input and output sequences from `buf`
18
+ according to `mode`.
19
+
20
+ *Ensures:*
21
+
22
+ - If `ios_base::out` is set in `mode`, `pbase()` points to `buf.front()`
23
+ and `epptr() >= pbase() + buf.size()` is `true`;
24
+ - in addition, if `ios_base::ate` is set in `mode`,
25
+ `pptr() == pbase() + buf.size()` is `true`,
26
+ - otherwise `pptr() == pbase()` is `true`.
27
+ - If `ios_base::in` is set in `mode`, `eback()` points to `buf.front()`,
28
+ and `(gptr() == eback() && egptr() == eback() + buf.size())` is
29
+ `true`.
30
+
31
+ [*Note 1*: For efficiency reasons, stream buffer operations might
32
+ violate invariants of `buf` while it is held encapsulated in the
33
+ `basic_stringbuf`, e.g., by writing to characters in the range
34
+ \[`buf.data() + buf.size()`, `buf.data() + buf.capacity()`). All
35
+ operations retrieving a `basic_string` from `buf` ensure that the
36
+ `basic_string` invariants hold on the returned value. — *end note*]
37
+
38
+ ``` cpp
39
+ allocator_type get_allocator() const noexcept;
40
+ ```
41
+
42
+ *Returns:* `buf.get_allocator()`.
43
+
44
+ ``` cpp
45
+ basic_string<charT, traits, Allocator> str() const &;
46
+ ```
47
+
48
+ *Effects:* Equivalent to:
49
+
50
+ ``` cpp
51
+ return basic_string<charT, traits, Allocator>(view(), get_allocator());
52
+ ```
53
+
54
  ``` cpp
55
+ template<class SAlloc>
56
+ basic_string<charT, traits, SAlloc> str(const SAlloc& sa) const;
57
+ ```
58
+
59
+ *Constraints:* `SAlloc` is a type that qualifies as an
60
+ allocator [[container.requirements.general]].
61
+
62
+ *Effects:* Equivalent to:
63
+
64
+ ``` cpp
65
+ return basic_string<charT, traits, SAlloc>(view(), sa);
66
+ ```
67
+
68
+ ``` cpp
69
+ basic_string<charT, traits, Allocator> str() &&;
70
+ ```
71
+
72
+ *Returns:* A `basic_string<charT, traits, Allocator>` object move
73
+ constructed from the `basic_stringbuf`’s underlying character sequence
74
+ in `buf`. This can be achieved by first adjusting `buf` to have the same
75
+ content as `view()`.
76
+
77
+ *Ensures:* The underlying character sequence `buf` is empty and
78
+ `pbase()`, `pptr()`, `epptr()`, `eback()`, `gptr()`, and `egptr()` are
79
+ initialized as if by calling `init_buf_ptrs()` with an empty `buf`.
80
+
81
+ ``` cpp
82
+ basic_string_view<charT, traits> view() const noexcept;
83
+ ```
84
+
85
+ Let `sv` be `basic_string_view<charT, traits>`.
86
+
87
+ *Returns:* A `sv` object referring to the `basic_stringbuf`’s underlying
88
+ character sequence in `buf`:
89
+
90
+ - If `ios_base::out` is set in `mode`, then
91
+ `sv(pbase(), high_mark-pbase())` is returned.
92
+ - Otherwise, if `ios_base::in` is set in `mode`, then
93
+ `sv(eback(), egptr()-eback())` is returned.
94
+ - Otherwise, `sv()` is returned.
95
+
96
+ [*Note 2*: Using the returned `sv` object after destruction or
97
+ invalidation of the character sequence underlying `*this` is undefined
98
+ behavior, unless `sv.empty()` is `true`. — *end note*]
99
 
100
  ``` cpp
101
  void str(const basic_string<charT, traits, Allocator>& s);
102
  ```
103
 
104
+ *Effects:* Equivalent to:
105
+
106
+ ``` cpp
107
+ buf = s;
108
+ init_buf_ptrs();
109
+ ```
110
+
111
+ ``` cpp
112
+ template<class SAlloc>
113
+ void str(const basic_string<charT, traits, SAlloc>& s);
114
+ ```
115
+
116
+ *Constraints:* `is_same_v<SAlloc,Allocator>` is `false`.
117
+
118
+ *Effects:* Equivalent to:
119
+
120
+ ``` cpp
121
+ buf = s;
122
+ init_buf_ptrs();
123
+ ```
124
+
125
+ ``` cpp
126
+ void str(basic_string<charT, traits, Allocator>&& s);
127
+ ```
128
+
129
+ *Effects:* Equivalent to:
130
+
131
+ ``` cpp
132
+ buf = std::move(s);
133
+ init_buf_ptrs();
134
+ ```
135