Order of evaluation in C++ function parameters

后端 未结 6 945
野性不改
野性不改 2020-11-22 00:41

If we have three functions (foo, bar, and baz) that are composed like so...

foo(bar(), baz())

Is there any guarantee by the C++ standard th

6条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-22 01:06

    There's no specified order for bar() and baz() - the only thing the Standard says is that they will both be evaluated before foo() is called. From the C++ Standard, section 5.2.2/8:

    The order of evaluation of arguments is unspecified.

提交回复
热议问题