mirror of
https://github.com/wichtounet/thor-os.git
synced 2025-09-17 08:37:17 -04:00
Implement constructors in terms of the assignment operators
This commit is contained in:
parent
1ca5058c84
commit
2d58587b7c
@ -16,10 +16,7 @@ string::string(size_t capacity){
|
||||
}
|
||||
|
||||
string::string(const string& rhs){
|
||||
_size = rhs._size;
|
||||
_capacity = rhs._capacity;
|
||||
_data = new char[_capacity];
|
||||
memcopy(_data, rhs._data, _capacity);
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
string& string::operator=(const string& rhs){
|
||||
@ -34,13 +31,7 @@ string& string::operator=(const string& rhs){
|
||||
}
|
||||
|
||||
string::string(string&& rhs){
|
||||
_size = rhs._size;
|
||||
_capacity = rhs._capacity;
|
||||
_data = rhs._data;
|
||||
|
||||
rhs._size = 0;
|
||||
rhs._capacity = 0;
|
||||
rhs._data = nullptr;
|
||||
*this = rhs;
|
||||
}
|
||||
|
||||
string& string::operator=(string&& rhs){
|
||||
|
Loading…
x
Reference in New Issue
Block a user