| ||||
| Comment on GotW #7b: Minimizing Compile-Time Dependencies, Part 2 by Alf P. Steinbach
Oh well. Hm. @Thibaud reminded me to add an So, here’s an implementation using void X::swap_with( X& other ) { swap<A>( *this, *this ); swap<B>( *this, *this ); swap( p_impl_, other.p_impl_ ); } If the no-throw swappable assumption does not hold, then a In the case where swapping throws one can end up with an inconsistent state, which is the same general effect as with the compiler-generated assignment for the original class Summing up so far, to implement a class • classes • the base classes If instead of a user-defined Comment on GotW #7a Solution: Minimizing Compile-Time Dependencies, Part 1 by JonKalb
Excellent comment Sebastian. Read More »Comment on GotW #7b: Minimizing Compile-Time Dependencies, Part 2 by Alf P. Steinbach
void X::swap_with( X& other ) And having corrected that it now occurred to me, what if In that case, since the above code swaps the virtual base sub-object an even number of times, an extra swap of it needs to be added to bring the total number of swaps of this sub-object to an odd number: void X::swap_with( X& other ) But if that swap is done via copy assignments and is costly, then this is needlessly inefficient. For, instead – and I didn’t think of this earlier – to cater for the possibility of a common virtual base class for auto X::operator=( X const& other ) I don’t think I’d do that optimization, but then, I don’t think I’d use PIMPL to get rid of an Comment on GotW #7a Solution: Minimizing Compile-Time Dependencies, Part 1 by daramarak
Sebastians comment is truly excellent, Sutter should definitely consider incorporating these explanations into the solution. Read More » | ||||
| | ||||
| ||||
Friday, August 23, 2013
FeedaMail: Comments for Sutterâs Mill
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment