Is RVO (Return Value Optimization) on unnamed objects a universally guaranteed behavior?

后端 未结 3 1829
傲寒
傲寒 2021-01-13 03:04

This question is in different aspect (also limited to gcc). My question is meant only for unnamed objects. Return Value Optimization is allowed to chang

3条回答
  •  无人及你
    2021-01-13 03:52

    Pedantically speaking its implementation defined. Modern compilers are intelligent enough to do such kind of optimization.

    But there is no guarantee that the behavior would be exactly same across implementations. That's what implementation defined behavior is all about.

    "allowed to" in this context means that 0 or 1 or 2 are standard conforming outputs.

提交回复
热议问题