mirror of
https://github.com/isocpp/CppCoreGuidelines.git
synced 2024-03-22 13:30:58 +08:00
Applied the suggestion in PR #238.
This commit is contained in:
parent
12dd788e1d
commit
50e89327bb
|
@ -4583,7 +4583,7 @@ The `swap` implementation technique offers the [strong guarantee](???).
|
|||
|
||||
##### Example
|
||||
|
||||
But what if you can get significant better performance by not making a temporary copy? Consider a simple `Vector` intended for a domain where assignment of large, equal-sized `Vector`s is common. In this case, the copy of elements implied by the `swap` implementation technique could cause an order of magnitude increase in cost:
|
||||
But what if you can get significantly better performance by not making a temporary copy? Consider a simple `Vector` intended for a domain where assignment of large, equal-sized `Vector`s is common. In this case, the copy of elements implied by the `swap` implementation technique could cause an order of magnitude increase in cost:
|
||||
|
||||
template<typename T>
|
||||
class Vector {
|
||||
|
@ -4608,7 +4608,7 @@ But what if you can get significant better performance by not making a temporary
|
|||
return *this;
|
||||
}
|
||||
|
||||
By writing directly to the target elements, we will get only [the basic guarantee](#???) rather than the strong guaranteed offered by the `swap` technique. Beware of [self assignment](#Rc-copy-self).
|
||||
By writing directly to the target elements, we will get only [the basic guarantee](#???) rather than the strong guarantee offered by the `swap` technique. Beware of [self assignment](#Rc-copy-self).
|
||||
|
||||
**Alternatives**: If you think you need a `virtual` assignment operator, and understand why that's deeply problematic, don't call it `operator=`. Make it a named function like `virtual void assign(const Foo&)`.
|
||||
See [copy constructor vs. `clone()`](#Rc-copy-virtual).
|
||||
|
|
Loading…
Reference in New Issue
Block a user