Re: Assignment exception guarantees
On 18 Sep., 03:08, Mark Zaytsev <mark.zayt...@gmail.com> wrote:
Does standard provide any rule / guarantees on order
of expression evaluation for operator = in expression like
throwing_function1() = throwing_function2();
if this functions have side effects cleanup become questionable.
[ example std::map< Key, Value > a_map; a_map[ a_key ] = a_value(); ]
thank you for advise
In the following I refer to the current working draft,
because C++03 doesn't specify much at all for this
situation. One relevant quote here is [expr.ass]/1:
"In all cases, the assignment is sequenced after the
value computation of the right and left operands, and
before the value computation of the assignment expression."
This guarantees that the final assignment of the
assignment to the lvalue referred to by
throwing_function1() will be done *after* evaluating
the function calls throwing_function1() and
throwing_function2(). *But* throwing_function1() and
throwing_function2() are indeterminately sequenced
as of [intro.execution]/15. This means that you
the call order of these functions is not determined.
HTH & Greetings from Bremen,
Daniel Kr?gler
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]