Fix ADL Participation for `swap` in 105-copy-swap.md (#4925)

pull/5009/head^2
Ali Ashkani Nia 7 months ago committed by GitHub
parent 7c5b49876a
commit c1fb58dab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      src/data/roadmaps/cpp/content/112-idioms/105-copy-swap.md

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

Loading…
Cancel
Save