От: | vdimas | ||
Дата: | 08.06.15 19:58 | ||
Оценка: |
You are right. Passing generator by reference to a function that you cannot see into the body, should inhibit this optimization.
Since lifetime can be stolen via move.
>> Unless generator<T> has unspecified and surprising semantics[1], no, it is not the same, In the examples I'm swapping the generator of 'baz' with another generator with a different lifetime.
What I meant is that applying heap elision optimization is unsafe and thus should not happen in this example.
Sure, generator is movable. Coroutine state is not. Therefore, if move happens or you cannot prove that it cannot happen as in you baz() example. Coroutine Frame Allocation Elision Optimization (CFAEO should be inhibited.