add move constructor, assignment to String class
This commit is contained in:
parent
d82996d684
commit
41c3dfc96e
|
|
@ -368,12 +368,19 @@ public:
|
||||||
String( const String& other )
|
String( const String& other )
|
||||||
: Buffer( other ){
|
: Buffer( other ){
|
||||||
}
|
}
|
||||||
|
String( String&& other ) noexcept {
|
||||||
|
swap( other );
|
||||||
|
}
|
||||||
|
|
||||||
String& operator=( const String& other ){
|
String& operator=( const String& other ){
|
||||||
String temp( other );
|
String temp( other );
|
||||||
temp.swap( *this );
|
temp.swap( *this );
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
String& operator=( String&& other ) noexcept {
|
||||||
|
swap( other );
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
String& operator=( const char* string ){
|
String& operator=( const char* string ){
|
||||||
String temp( string );
|
String temp( string );
|
||||||
temp.swap( *this );
|
temp.swap( *this );
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user