Fix call unwrapping optimization by AlexGuteniev · Pull Request #5919 · microsoft/STL (original) (raw)
Fix regression in #5808.
We can't move out lvalue reference.
The optimization for lvalue references is still possible, but we have to handle this case slightly differently.
Now, if the function is passed as lvalue, we copy from the passed function. instead of moving it out.
Other cases of lvalue reference in call unwrapping:
- Inner
move_only_function: [func.wrap.move.ctor]/6 and the definition ofmove_only_functionenforces that attempt to use lvalue reference here won't compile. So no handling is needed. - Inner
copyable_function: will need to handle lvalue reference with this approach applied in one more place, in addition to these three places - Inner
function_ref. There can be lvalue references. But I don't know if we want to nullify moved-outfunction_refor not. More natural would be to leave moved outfunction_refintact, so we will always do as if we have lvalue reference.