lager
lager copied to clipboard
Fix double std::move on objects in 'lenses::getset' on set call
This is the final version of the patch that fixes both, double-move problem and extra getter call on set(lens,...)
operation.
The patch ensures the following requirements:
-
When
view(lens, whole)
is called:-
the setter lambda is neither called nor constructed. It avoids unnecessary copies of the 'whole' object.
-
the
whole
object is directly forwarded into the getter lambda, without any copies.
-
-
When
set(lens, whole, part)
is called:-
no getter is called at the toplevel lens (which value was previously discarded).
-
on the lower lenses, the getter receives an 'lvalue' reference to the
whole
object, and setter receives an 'rvalue' reference to thewhole
object. It ensures that there is no double-move problem.
-
Fixes #160