
on Thu Sep 11 2008, Gevorg Voskanyan <v_gevorg-AT-yahoo.com> wrote:
David Abrahams wrote:
on Thu Sep 11 2008, Gevorg Voskanyan wrote:
[snip]
AFAIU, a swapping assignment operator taking the parameter by const ref adheres to the strong exception safety guarantee, whereas the one taking the parameter by value fulfills the nothrow guarantee. Not sure how practical and/or relevant the difference in this context is, though.
Is my observation above correct?
Well, technically, yeah... although the expression that does the assignment can still throw, so I don't think it makes much difference to say that it's nothrow. In other words, if I give you
f(std::string); // nothrow g(std::string&); // strong guarantee
For all practical purposes, you know that f and g have equivalent exception behavior because std::string's copy ctor can throw.
True, that's why I questioned the practicality of this difference :) Except perhaps for documenting a function's exception safety. Should it be considered while making aforementioned assignment operators in boost to take the argument by value?
If you're asking whether such functions should be documented as nothrow after the modification, I think they should: it could be useful information for move-only types (with nonthrowing move ctors). -- Dave Abrahams BoostPro Computing http://www.boostpro.com