May 12, 2011, 8:55 p.m.
posted by nogood
Axiom 3: Swap Doesn't ThrowThis is another socially based axiom, but it's not as ingrained and universally recognized as the prohibition on destructors and deletions that throw. Swapping would not seem to be a very common operation, but it is used extensively "behind the scenes," most particularly in STL implementations. Whenever you perform a sort, reverse, partition, or any of a large number of other operations, you're swapping, and an exception safe swap goes a long way toward guaranteeing that these operations will be exception safe as well. See also Copy Operations [13, 45]. |
- Comment