Re: <map> erase

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



aa <ss> wrote:
> "Stephen Howe" <sjhoweATdialDOTpipexDOTcom> wrote in message
> news:%23YpNagVyFHA.664@xxxxxxxxxxxxxxxxxxxxxxx
>>> Hmm, wait, I don't understand how that is proper. In ++x, the
>>> iterator is incremented before being passed to erase. In x++, the
>>> iterator is incremented after being passed to erase...
>>
>> The increments are not supposed to occur after the function call.
>
> Is this documented somewhere?

C++ standard:

1.9/7 Accessing an object designated by a volatile lvalue (3.10),
modifying an object, calling a library I/O function, or calling a
function that does any of those operations are all side effects, which
are changes in the state of the execution environment. Evaluation of an
expression might produce side effects. At certain specified points in
the execution sequence called sequence points, all side effects of
previous evaluations shall be complete and no side effects of subsequent
evaluations shall have taken place.

1.9/17 When calling a function (whether or not the function is inline),
there is a sequence point after the evaluation of all function arguments
(if any) which takes place before execution of any expressions or
statements in the function body.

5.2.6/1 The value obtained by applying a postfix ++ is the value that
the operand had before applying the operator. [Note: the value obtained
is a copy of the original value ] The operand shall be a modifiable
lvalue. The type of the operand shall be an arithmetic type or a pointer
to a complete object type. After the result is noted, the value of the
object is modified by adding 1 to it, unless the object is of type bool,
in which case it is set to true. [Note: this use is deprecated, see
annex D. ] The result is an rvalue. The type of the result is the
cv-unqualified version of the type of the operand.

--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925


.



Relevant Pages

  • Re: Must an expression be evaluated before its value is used?
    ... this is not a sequence point. ... The evaluation dependency has a consequence of ... seperate the assignment of 5 to x from the assignment of 11 to x. ... comma operator without first evaluating it's second operand. ...
    (comp.std.c)
  • Re: Must an expression be evaluated before its value is used?
    ... properly define the ordering of sequence points. ... The evaluation order is defined by the abstract machine (even if it is ... there is a sequence point after the evaluation of the first operand. ... "2 The left operand of a comma operator is evaluated as a void ...
    (comp.std.c)
  • Re: function call?
    ... I was under the incorrect impression that there's a sequence point after ... If the evaluation occurs before that ... if the DS9K documents that the LHS operand is evaluated before the RHS ... assignment expression is unspecified. ...
    (comp.lang.c)
  • Re: x=(x=5,11)
    ... The phrase "partial ordering" is not used by the Standard. ... A partial ordering is an ordering inposed on a sequence of events ... The side effect of updating the stored value of the left operand ... there is a sequence point after its evaluation. ...
    (comp.lang.c)
  • Re: question about "++"
    ... You need to distinguish between the evaluation of an operator ... The ++ operator always evaluates to the original value of its operand. ... it increments the value of the operand....... ... And, as you say in the next paragraph, understanding that "timing" ...
    (comp.lang.c)