File tree 2 files changed +18
-44
lines changed
Filter options
2 files changed +18
-44
lines changed
Original file line number Diff line number Diff line change @@ -63,18 +63,15 @@ String::String(const __FlashStringHelper *pstr)
63
63
*this = pstr;
64
64
}
65
65
66
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
67
66
String::String (String &&rval)
67
+ : buffer(rval.buffer)
68
+ , capacity(rval.capacity)
69
+ , len(rval.len)
68
70
{
69
- init ();
70
- move (rval);
71
+ rval.buffer = NULL ;
72
+ rval.capacity = 0 ;
73
+ rval.len = 0 ;
71
74
}
72
- String::String (StringSumHelper &&rval)
73
- {
74
- init ();
75
- move (rval);
76
- }
77
- #endif
78
75
79
76
String::String (char c)
80
77
{
@@ -214,28 +211,21 @@ String & String::copy(const __FlashStringHelper *pstr, unsigned int length)
214
211
return *this ;
215
212
}
216
213
217
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
218
214
void String::move (String &rhs)
219
215
{
220
- if (buffer) {
221
- if (rhs && capacity >= rhs.len ) {
222
- memcpy (buffer, rhs.buffer , rhs.len );
223
- len = rhs.len ;
224
- buffer[len] = ' \0 ' ;
225
- rhs.len = 0 ;
226
- return ;
227
- } else {
228
- free (buffer);
229
- }
216
+ if (this != &rhs)
217
+ {
218
+ free (buffer);
219
+
220
+ buffer = rhs.buffer ;
221
+ len = rhs.len ;
222
+ capacity = rhs.capacity ;
223
+
224
+ rhs.buffer = NULL ;
225
+ rhs.len = 0 ;
226
+ rhs.capacity = 0 ;
230
227
}
231
- buffer = rhs.buffer ;
232
- capacity = rhs.capacity ;
233
- len = rhs.len ;
234
- rhs.buffer = NULL ;
235
- rhs.capacity = 0 ;
236
- rhs.len = 0 ;
237
228
}
238
- #endif
239
229
240
230
String & String::operator = (const String &rhs)
241
231
{
@@ -247,19 +237,11 @@ String & String::operator = (const String &rhs)
247
237
return *this ;
248
238
}
249
239
250
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
251
240
String & String::operator = (String &&rval)
252
241
{
253
- if (this != &rval) move (rval);
254
- return *this ;
255
- }
256
-
257
- String & String::operator = (StringSumHelper &&rval)
258
- {
259
- if (this != &rval) move (rval);
242
+ move (rval);
260
243
return *this ;
261
244
}
262
- #endif
263
245
264
246
String & String::operator = (const char *cstr)
265
247
{
Original file line number Diff line number Diff line change @@ -72,10 +72,7 @@ class String
72
72
String (const uint8_t *cstr, unsigned int length) : String((const char *)cstr, length) {}
73
73
String (const String &str);
74
74
String (const __FlashStringHelper *str);
75
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
76
75
String (String &&rval);
77
- String (StringSumHelper &&rval);
78
- #endif
79
76
explicit String (char c);
80
77
explicit String (unsigned char , unsigned char base=10 );
81
78
explicit String (int , unsigned char base=10 );
@@ -99,10 +96,7 @@ class String
99
96
String & operator = (const String &rhs);
100
97
String & operator = (const char *cstr);
101
98
String & operator = (const __FlashStringHelper *str);
102
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
103
99
String & operator = (String &&rval);
104
- String & operator = (StringSumHelper &&rval);
105
- #endif
106
100
107
101
// concatenate (works w/ built-in types)
108
102
@@ -233,9 +227,7 @@ class String
233
227
// copy and move
234
228
String & copy (const char *cstr, unsigned int length);
235
229
String & copy (const __FlashStringHelper *pstr, unsigned int length);
236
- #if __cplusplus >= 201103L || defined(__GXX_EXPERIMENTAL_CXX0X__)
237
230
void move (String &rhs);
238
- #endif
239
231
};
240
232
241
233
class StringSumHelper : public String
You can’t perform that action at this time.
0 commit comments