
11 Sep
2008
11 Sep
'08
1:23 a.m.
Joel Falcou wrote:
I may come late and maybe like an unwanted guest in this discussion but I am curious to know how i can know that for a given class of mine, the swap value operator= is better than the by const ref operator= ?
My rule of thumb is that if your assignment operator might throw an exception and you want assignment to fulfill the strong exception safety guarantee (i.e. either the assignment succeeds or the target remains unchanged) then you should consider the swapping operator=. Joe Gottman