-
-
Notifications
You must be signed in to change notification settings - Fork 69
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix double std::move on objects in 'lenses::getset' on set call #165
base: master
Are you sure you want to change the base?
Changes from 6 commits
b863b87
596983f
51e3c0e
3ea51d9
af07b69
ce03ff3
0b6ab3e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
#pragma once | ||
|
||
#include <lager/lenses.hpp> | ||
#include <lager/util.hpp> | ||
#include <zug/compose.hpp> | ||
|
||
|
@@ -17,15 +18,14 @@ namespace lenses { | |
template <typename Member> | ||
auto attr(Member member) | ||
{ | ||
return zug::comp([member](auto&& f) { | ||
return [&, f = LAGER_FWD(f)](auto&& p) { | ||
return f(LAGER_FWD(p).*member)([&](auto&& x) { | ||
auto r = LAGER_FWD(p); | ||
r.*member = LAGER_FWD(x); | ||
return r; | ||
}); | ||
}; | ||
}); | ||
return getset( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi, @arximboldi! I had to rewrite auto birthday_lens = attr(&debug_person::birthday);
auto person_lens = attr(&debug_freelancer::person);
auto freelancer_birthday_lens = person_lens | birthday_lens;
auto birthday =
set(freelancer_birthday_lens,
debug_freelancer(freelancer_copy_info, person_copy_info, birthday_copy_info),
debug_yearday(birthday_copy_info)); I have a weird feeling like all the lenses in lager have to be rewritten like that... :( Not only they do double-move, capturing functors into immutable lambdas prevents proper forwarding of the identity functors in |
||
[=](auto &&p) -> decltype(auto) { | ||
return LAGER_FWD(p).*member; | ||
}, | ||
[=](auto p, auto &&x) { | ||
p.*member = LAGER_FWD(x); | ||
return p; | ||
}); | ||
} | ||
|
||
//! @} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note: the change to
const Getter& getter
is not a regression, because they were previously bound to a const reference inside a const (immutable) lambda.