要触发nrvo, 返回值写在第一行, 然后return语句和返回值处于同一block.
如果代码有if动态分支,你在if里边返回的时候触发不了nrvo.
我感觉nrvo是一个编译期行为, 编译器如果无法预测你的分支,nrvo就不可能.
【 在 allegro (静水流深) 的大作中提到: 】
: I read again the NRVO carefully, seems I mis-understand the NRVO in case 5.
: NRVO needs to know which variable to return at construction.
: But still I have question for case-5, const effectively blocks the move ctor.
: ...................
--
FROM 120.244.224.*