3 ms·
Most of the time. In container like code, copy/swap gives easy strong exception guarantee, but that is rarely needed
by beached_whale 4y ago
Most of the time. In container like code, copy/swap gives easy strong exception guarantee, but that is rarely needed
- nly 4y agoAchieving exception safety while copying containers, specifically, is generally simple because their states tend to be very easy to reason about. For example, making sure you destroy elements 0 thru [n-1] in a vector if inserting element [n] in to it fails. Move, and thus swap (since it's 3 moves), should essentially always be noexcept (never throw)