Is the compiler allowed to eliminate the copy that is required for the by-value capture?
vector<Image> movie1;
apply( [=movie1](){ return movie1.size(); } );
- Is there any circumstance that the compiler does not need to copy
movie1
?- Maybe if the compiler could know, that
apply
does not actually changemovie1
? - Or does it help that Lambdas are by default
const
functors in any case?
- Maybe if the compiler could know, that
- Does it help at all that
vector
has a move constructor and move assign?- If yes, is it required to add these to
Image
as well, to prevent an expensive copy here?
- If yes, is it required to add these to
- Is there a difference in the mechanism when and how a copy is required for by-value capture compared to by-value arguments? eg.
void operate(vector<Image> movie)
?