mirror of
https://github.com/kamranahmedse/developer-roadmap.git
synced 2025-08-05 16:57:27 +02:00
Fix ADL Participation for swap
in 105-copy-swap.md (#4925)
This commit is contained in:
@@ -16,14 +16,14 @@ class String {
|
|||||||
|
|
||||||
String(const String& other);
|
String(const String& other);
|
||||||
|
|
||||||
void swap(String& other) {
|
friend void swap(String& first, String& second) {
|
||||||
using std::swap; // for arguments-dependent lookup (ADL)
|
using std::swap; // for arguments-dependent lookup (ADL)
|
||||||
swap(size_, other.size_);
|
swap(first.size_, second.size_);
|
||||||
swap(buffer_, other.buffer_);
|
swap(first.buffer_, second.buffer_);
|
||||||
}
|
}
|
||||||
|
|
||||||
String& operator=(String other) {
|
String& operator=(String other) {
|
||||||
swap(other);
|
swap(*this, other);
|
||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
Reference in New Issue
Block a user