add move constructor, assignment to String class

This commit is contained in:
Garux 2021-08-18 01:24:53 +03:00
parent d82996d684
commit 41c3dfc96e

View File

@ -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 );