'Vlad from Moscow' via ISO C++ Standard - Discussion
2018-10-12 22:51:02 UTC
In the C++ Standard there is written according to the compound operator ( *8.5.18
Assignment and compound assignment operators, p.#7):*
7 The behavior of an expression of the form E1 *op *= E2 is equivalent to E1
s = s + strlen( s ) - 1;
where s has type char *. If s is a pointer to an empty string then the
statement is equivalent to
s = s - 1;
However if to rewrite the statement like
s += strlen( s ) - 1;
Then the statement is equivalent to
s = s + std::numeric_limits<size_t>::max();
So it looks like E1 op = E2 is not equivalent to E1 = E1 op E2.
Assignment and compound assignment operators, p.#7):*
7 The behavior of an expression of the form E1 *op *= E2 is equivalent to E1
= E1 *op *E2 except that E1 is
evaluated only once.
However I doubt whether this phrase is correct.
Consider the following code snippetevaluated only once.
However I doubt whether this phrase is correct.
s = s + strlen( s ) - 1;
where s has type char *. If s is a pointer to an empty string then the
statement is equivalent to
s = s - 1;
However if to rewrite the statement like
s += strlen( s ) - 1;
Then the statement is equivalent to
s = s + std::numeric_limits<size_t>::max();
So it looks like E1 op = E2 is not equivalent to E1 = E1 op E2.
--
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.
---
You received this message because you are subscribed to the Google Groups "ISO C++ Standard - Discussion" group.
To unsubscribe from this group and stop receiving emails from it, send an email to std-discussion+***@isocpp.org.
To post to this group, send email to std-***@isocpp.org.
Visit this group at https://groups.google.com/a/isocpp.org/group/std-discussion/.