File tree 2 files changed +18
-43
lines changed
2 files changed +18
-43
lines changed Original file line number Diff line number Diff line change @@ -45,18 +45,15 @@ String::String(const __FlashStringHelper *pstr)
45
45
*this = pstr;
46
46
}
47
47
48
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
49
48
String::String (String &&rval)
49
+ : buffer(rval.buffer)
50
+ , capacity(rval.capacity)
51
+ , len(rval.len)
50
52
{
51
- init ();
52
- move (rval);
53
+ rval.buffer = NULL ;
54
+ rval.capacity = 0 ;
55
+ rval.len = 0 ;
53
56
}
54
- String::String (StringSumHelper &&rval)
55
- {
56
- init ();
57
- move (rval);
58
- }
59
- #endif
60
57
61
58
String::String (char c)
62
59
{
@@ -191,27 +188,21 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
191
188
return *this ;
192
189
}
193
190
194
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
195
191
void String::move (String &rhs)
196
192
{
197
- if (buffer) {
198
- if (rhs && capacity >= rhs.len ) {
199
- strcpy (buffer, rhs.buffer );
200
- len = rhs.len ;
201
- rhs.len = 0 ;
202
- return ;
203
- } else {
204
- free (buffer);
205
- }
193
+ if (this != &rhs)
194
+ {
195
+ free (buffer);
196
+
197
+ buffer = rhs.buffer ;
198
+ len = rhs.len ;
199
+ capacity = rhs.capacity ;
200
+
201
+ rhs.buffer = NULL ;
202
+ rhs.len = 0 ;
203
+ rhs.capacity = 0 ;
206
204
}
207
- buffer = rhs.buffer ;
208
- capacity = rhs.capacity ;
209
- len = rhs.len ;
210
- rhs.buffer = NULL ;
211
- rhs.capacity = 0 ;
212
- rhs.len = 0 ;
213
205
}
214
- #endif
215
206
216
207
String & String::operator = (const String &rhs)
217
208
{
@@ -223,19 +214,11 @@ String & String::operator = (const String &rhs)
223
214
return *this ;
224
215
}
225
216
226
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
227
217
String & String::operator = (String &&rval)
228
218
{
229
- if (this != &rval) move (rval);
230
- return *this ;
231
- }
232
-
233
- String & String::operator = (StringSumHelper &&rval)
234
- {
235
- if (this != &rval) move (rval);
219
+ move (rval);
236
220
return *this ;
237
221
}
238
- #endif
239
222
240
223
String & String::operator = (const char *cstr)
241
224
{
Original file line number Diff line number Diff line change @@ -63,10 +63,7 @@ class String
63
63
String (const char *cstr = " " );
64
64
String (const String &str);
65
65
String (const __FlashStringHelper *str);
66
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
67
66
String (String &&rval);
68
- String (StringSumHelper &&rval);
69
- #endif
70
67
explicit String (char c);
71
68
explicit String (unsigned char , unsigned char base=10 );
72
69
explicit String (int , unsigned char base=10 );
@@ -90,10 +87,7 @@ class String
90
87
String & operator = (const String &rhs);
91
88
String & operator = (const char *cstr);
92
89
String & operator = (const __FlashStringHelper *str);
93
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
94
90
String & operator = (String &&rval);
95
- String & operator = (StringSumHelper &&rval);
96
- #endif
97
91
98
92
// concatenate (works w/ built-in types)
99
93
@@ -223,9 +217,7 @@ class String
223
217
// copy and move
224
218
String & copy (const char *cstr, unsigned int length);
225
219
String & copy (const __FlashStringHelper *pstr, unsigned int length);
226
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
227
220
void move (String &rhs);
228
- #endif
229
221
};
230
222
231
223
class StringSumHelper : public String
You can’t perform that action at this time.
0 commit comments