'Can someone explain time complexity for swap() in C++?
I was looking at documentation here for the method std::swap() (https://www.cplusplus.com/reference/algorithm/swap/), and I'm a bit confused at this statement:
Notice how this function involves a copy construction and two assignment operations, which may not be the most efficient way of swapping the contents of classes that store large quantities of data, since each of these operations generally operate in linear time on their size.
I understand that a copy construction would be a linear operation, but why would the two assignment operations be linear if they are references? There's not really any copying going on there, we're just changing references, correct?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
