문제

According to this precedence table, the comma operator is left-associative. That is, a, b, c is parsed as (a, b), c. Is that a necessity? Wouldn't a, (b, c) have the exact same behavior?

도움이 되었습니까?

해결책

Since overloadable operator, exists, no, it's not the same behavior. a, (b, c) could call different overloads than (a, b), c.

다른 팁

The comma operator has left-to-right associativity. Two expressions separated by a comma are evaluated left to right. The left operand is always evaluated, and all side effects are completed before the right operand is evaluated.

Commas can be used as separators in some contexts, such as function argument lists. Do not confuse the use of the comma as a separator with its use as an operator; the two uses are completely different.

http://msdn.microsoft.com/en-us/library/zs06xbxh.aspx

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top