От: | Evgeny.Panasyuk | ||
Дата: | 08.06.15 21:03 | ||
Оценка: |
V>You are right. Passing generator by reference to a function that you cannot see into the body, should inhibit this optimization.
V>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.
V>What I meant is that applying heap elision optimization is unsafe and thus should not happen in this example.
V>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.