@@ -24,14 +24,16 @@ class val<std::basic_string<CharT, Traits>> {
24
24
val (val<std::basic_string<CharT, Traits>*> str) : data_ptr(str) {
25
25
}
26
26
val (const val<const CharT*>& s) : data_ptr(nullptr ) {
27
- data_ptr = invoke (+[](const CharT* s) -> base_type* { return new base_type (s); }, s);
27
+ data_ptr = invoke (
28
+ +[](const CharT* s) -> base_type* { return new base_type (s); }, s);
28
29
}
29
30
30
31
val (const CharT* s) : val(val<const CharT*>(s)) {
31
32
}
32
33
33
34
val<CharT> at (val<size_type> pos) {
34
- return invoke (+[](base_type* ptr, size_type p) -> CharT { return ptr->at (p); }, data_ptr, pos);
35
+ return invoke (
36
+ +[](base_type* ptr, size_type p) -> CharT { return ptr->at (p); }, data_ptr, pos);
35
37
}
36
38
37
39
/* *
@@ -41,19 +43,23 @@ class val<std::basic_string<CharT, Traits>> {
41
43
* If pos > size(), the behavior is undefined.
42
44
*/
43
45
val<CharT> operator [](val<size_type> pos) {
44
- return invoke (+[](base_type* ptr, size_type p) -> CharT { return ptr->operator [](p); }, data_ptr, pos);
46
+ return invoke (
47
+ +[](base_type* ptr, size_type p) -> CharT { return ptr->operator [](p); }, data_ptr, pos);
45
48
}
46
49
47
50
val<CharT> front () {
48
- return invoke (+[](base_type* ptr) -> CharT { return ptr->front (); }, data_ptr);
51
+ return invoke (
52
+ +[](base_type* ptr) -> CharT { return ptr->front (); }, data_ptr);
49
53
}
50
54
51
55
val<CharT> back () {
52
- return invoke (+[](base_type* ptr) -> CharT { return ptr->back (); }, data_ptr);
56
+ return invoke (
57
+ +[](base_type* ptr) -> CharT { return ptr->back (); }, data_ptr);
53
58
}
54
59
55
60
val<CharT*> data () {
56
- return invoke (+[](base_type* ptr) -> CharT* { return ptr->data (); }, data_ptr);
61
+ return invoke (
62
+ +[](base_type* ptr) -> CharT* { return ptr->data (); }, data_ptr);
57
63
}
58
64
59
65
/* *
@@ -63,55 +69,62 @@ class val<std::basic_string<CharT, Traits>> {
63
69
* character after the last position.
64
70
*/
65
71
val<const CharT*> c_str () const {
66
- return invoke (+[](base_type* ptr) -> const CharT* { return ptr->c_str (); }, data_ptr);
72
+ return invoke (
73
+ +[](base_type* ptr) -> const CharT* { return ptr->c_str (); }, data_ptr);
67
74
}
68
75
69
76
operator val<std::basic_string_view<CharT, Traits>>() const {
70
77
return val<std::basic_string_view<CharT, Traits>>(c_str ());
71
78
}
72
79
73
80
val<bool > empty () const {
74
- return invoke (+[](base_type* ptr) -> bool { return ptr->empty (); }, data_ptr);
81
+ return invoke (
82
+ +[](base_type* ptr) -> bool { return ptr->empty (); }, data_ptr);
75
83
}
76
84
77
85
/* *
78
86
* Returns the number of CharT elements in the string, i.e. std::distance(begin(), end()).
79
87
* @return
80
88
*/
81
89
val<size_type> size () const {
82
- return invoke (+[](base_type* ptr) -> size_type { return ptr->size (); }, data_ptr);
90
+ return invoke (
91
+ +[](base_type* ptr) -> size_type { return ptr->size (); }, data_ptr);
83
92
}
84
93
85
94
/* *
86
95
* Returns the number of CharT elements in the string, i.e. std::distance(begin(), end()).
87
96
* @return
88
97
*/
89
98
val<size_type> length () const {
90
- return invoke (+[](base_type* ptr) -> size_type { return ptr->length (); }, data_ptr);
99
+ return invoke (
100
+ +[](base_type* ptr) -> size_type { return ptr->length (); }, data_ptr);
91
101
}
92
102
93
103
/* *
94
104
* Returns the maximum number of characters
95
105
* @return
96
106
*/
97
107
val<size_type> max_size () const {
98
- return invoke (+[](base_type* ptr) -> size_type { return ptr->max_size (); }, data_ptr);
108
+ return invoke (
109
+ +[](base_type* ptr) -> size_type { return ptr->max_size (); }, data_ptr);
99
110
}
100
111
101
112
/* *
102
113
* Informs a std::basic_string object of a planned change in size, so that it can manage the storage allocation appropriately.
103
114
* @param new_cap
104
115
*/
105
116
void reserve (val<size_type> new_cap) const {
106
- return invoke (+[](base_type* ptr, size_type s) -> void { return ptr->reserve (s); }, data_ptr, new_cap);
117
+ return invoke (
118
+ +[](base_type* ptr, size_type s) -> void { return ptr->reserve (s); }, data_ptr, new_cap);
107
119
}
108
120
109
121
/* *
110
122
* Returns the number of characters that can be held in currently allocated storage.
111
123
* @return
112
124
*/
113
125
val<size_type> capacity () const {
114
- return invoke (+[](base_type* ptr) -> size_type { return ptr->capacity (); }, data_ptr);
126
+ return invoke (
127
+ +[](base_type* ptr) -> size_type { return ptr->capacity (); }, data_ptr);
115
128
}
116
129
117
130
/* *
@@ -120,91 +133,103 @@ class val<std::basic_string<CharT, Traits>> {
120
133
* @return
121
134
*/
122
135
void clear () const {
123
- invoke (+[](base_type* ptr) -> void { ptr->clear (); }, data_ptr);
136
+ invoke (
137
+ +[](base_type* ptr) -> void { ptr->clear (); }, data_ptr);
124
138
}
125
139
126
140
/* *
127
141
* Inserts characters into the string.
128
142
*/
129
143
auto & insert (val<size_type> index, val<size_type> count, val<CharT> ch) const {
130
- invoke (+[](base_type* ptr, size_type index, size_type count, CharT ch) -> void { ptr->insert (index, count, ch); }, data_ptr, index, count, ch);
144
+ invoke (
145
+ +[](base_type* ptr, size_type index, size_type count, CharT ch) -> void { ptr->insert (index, count, ch); }, data_ptr, index, count, ch);
131
146
return *this ;
132
147
}
133
148
134
149
/* *
135
150
* Inserts characters into the string.
136
151
*/
137
152
auto & insert (val<size_type> index, val<const CharT*> s) const {
138
- invoke (+[](base_type* ptr, size_type index, const CharT* s) -> void { ptr->insert (index, s); }, data_ptr, index, s);
153
+ invoke (
154
+ +[](base_type* ptr, size_type index, const CharT* s) -> void { ptr->insert (index, s); }, data_ptr, index, s);
139
155
return *this ;
140
156
}
141
157
142
158
/* *
143
159
* Appends additional characters to the string.
144
160
*/
145
161
auto & append (val<size_type> count, val<CharT> ch) {
146
- invoke (+[](base_type* ptr, size_type count, CharT ch) -> void { ptr->append (count, ch); }, data_ptr, count, ch);
162
+ invoke (
163
+ +[](base_type* ptr, size_type count, CharT ch) -> void { ptr->append (count, ch); }, data_ptr, count, ch);
147
164
return *this ;
148
165
}
149
166
150
167
/* *
151
168
* Appends additional characters to the string.
152
169
*/
153
170
auto & append (val<std::basic_string<CharT, Traits>>& str) {
154
- invoke (+[](base_type* ptr, base_type* other) -> void { ptr->append (*other); }, data_ptr, str.data_ptr );
171
+ invoke (
172
+ +[](base_type* ptr, base_type* other) -> void { ptr->append (*other); }, data_ptr, str.data_ptr );
155
173
return *this ;
156
174
}
157
175
158
176
/* *
159
177
* Appends additional characters to the string.
160
178
*/
161
179
auto & append (const val<std::basic_string<CharT, Traits>>& str, const val<size_type>& pos, const val<size_type>& count) {
162
- invoke (+[](base_type* ptr, base_type* other, size_type pos, size_type count) -> void { ptr->append (*other, pos, count); }, data_ptr, str.data_ptr , pos, count);
180
+ invoke (
181
+ +[](base_type* ptr, base_type* other, size_type pos, size_type count) -> void { ptr->append (*other, pos, count); }, data_ptr, str.data_ptr , pos, count);
163
182
return *this ;
164
183
}
165
184
166
185
/* *
167
186
* Appends additional characters to the string.
168
187
*/
169
188
auto & append (const val<std::basic_string<CharT, Traits>>& str, const val<size_type>& count) {
170
- invoke (+[](base_type* ptr, base_type* other, size_type count) -> void { ptr->append (*other, count); }, data_ptr, str.data_ptr , count);
189
+ invoke (
190
+ +[](base_type* ptr, base_type* other, size_type count) -> void { ptr->append (*other, count); }, data_ptr, str.data_ptr , count);
171
191
return *this ;
172
192
}
173
193
174
194
/* *
175
195
* Appends additional characters to the string.
176
196
*/
177
197
auto & append (const val<CharT*>& s, const val<size_type>& count) {
178
- invoke (+[](base_type* ptr, CharT* s, size_type count) -> void { ptr->append (s, count); }, data_ptr, s, count);
198
+ invoke (
199
+ +[](base_type* ptr, CharT* s, size_type count) -> void { ptr->append (s, count); }, data_ptr, s, count);
179
200
return *this ;
180
201
}
181
202
182
203
/* *
183
204
* Appends additional characters to the string.
184
205
*/
185
206
auto & append (const val<const CharT*>& s) {
186
- invoke (+[](base_type* ptr, const CharT* s) -> void { ptr->append (s); }, data_ptr, s);
207
+ invoke (
208
+ +[](base_type* ptr, const CharT* s) -> void { ptr->append (s); }, data_ptr, s);
187
209
return *this ;
188
210
}
189
211
190
212
/* *
191
213
* Appends additional characters to the string.
192
214
*/
193
215
auto & operator +=(const val<std::basic_string<CharT, Traits>>& str) {
194
- invoke (+[](base_type* ptr, base_type* s) -> void { ptr->operator +=(*s); }, data_ptr, str.data_ptr );
216
+ invoke (
217
+ +[](base_type* ptr, base_type* s) -> void { ptr->operator +=(*s); }, data_ptr, str.data_ptr );
195
218
return *this ;
196
219
}
197
220
198
221
/* *
199
222
* Appends additional characters to the string.
200
223
*/
201
224
auto & operator +=(const val<const CharT*>& s) {
202
- invoke (+[](base_type* ptr, const CharT* s) -> void { ptr->operator +=(s); }, data_ptr, s);
225
+ invoke (
226
+ +[](base_type* ptr, const CharT* s) -> void { ptr->operator +=(s); }, data_ptr, s);
203
227
return *this ;
204
228
}
205
229
206
230
auto & operator +=(const val<CharT*>& s) {
207
- invoke (+[](base_type* ptr, const CharT* s) -> void { ptr->operator +=(s); }, data_ptr, s);
231
+ invoke (
232
+ +[](base_type* ptr, const CharT* s) -> void { ptr->operator +=(s); }, data_ptr, s);
208
233
return *this ;
209
234
}
210
235
@@ -216,7 +241,8 @@ class val<std::basic_string<CharT, Traits>> {
216
241
* Copies a substring [pos, pos + count) to character string pointed to by dest. If the requested substring lasts past the end of the string, or if count == npos, the copied substring is [pos, size()).
217
242
*/
218
243
val<size_type> copy (const val<CharT*>& dest, const val<size_type>& count, const val<size_type>& pos = 0 ) {
219
- return invoke (+[](base_type* ptr, CharT* dest, size_type count, size_type pos) -> size_type { return ptr->copy (dest, count, pos); }, data_ptr, dest, count, pos);
244
+ return invoke (
245
+ +[](base_type* ptr, CharT* dest, size_type count, size_type pos) -> size_type { return ptr->copy (dest, count, pos); }, data_ptr, dest, count, pos);
220
246
}
221
247
222
248
~val () {
0 commit comments