Commit 2f107c8a authored by Kristen Parton's avatar Kristen Parton Committed by facebook-github-bot-9

Revert "[folly::gen] Prevent accidental moves in filter()"

Summary: This reverts commit aee49bc8a945db9ad6c0ef6a9598ca5c44a4dc8c.

Temporarily reverting the previous diff to investigate possible downstream regression.

Reviewed By: @yfeldblum

Differential Revision: D2359864
parent 0fdbb61e
......@@ -559,8 +559,7 @@ class Filter : public Operator<Filter<Predicate>> {
template <class Body>
void foreach(Body&& body) const {
source_.foreach([&](Value value) {
// NB: Argument not forwarded to avoid accidental move-construction
if (pred_(value)) {
if (pred_(std::forward<Value>(value))) {
body(std::forward<Value>(value));
}
});
......@@ -569,8 +568,7 @@ class Filter : public Operator<Filter<Predicate>> {
template <class Handler>
bool apply(Handler&& handler) const {
return source_.apply([&](Value value) -> bool {
// NB: Argument not forwarded to avoid accidental move-construction
if (pred_(value)) {
if (pred_(std::forward<Value>(value))) {
return handler(std::forward<Value>(value));
}
return true;
......
......@@ -289,15 +289,6 @@ TEST(Gen, FilterDefault) {
}
}
TEST(Gen, FilterSink) {
auto actual
= seq(1, 2)
| map([](int x) { return vector<int>{x}; })
| filter([](vector<int> v) { return !v.empty(); })
| as<vector>();
EXPECT_FALSE(from(actual) | rconcat | isEmpty);
}
TEST(Gen, Contains) {
{
auto gen =
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment