fix wrong std::move in Value::Filter::chain

Also, instance calls to Value::Filter::chain methods were moving the calling
instance while you may not want this in many cases.
This commit is contained in:
Simon Désaulniers committed 2016-05-05 16:29:59 -04:00
1 parent 92613f5fbf
commit 98a3960bf8
1 file changed
+8 -6
+8 -6
View File
@@ -130,6 +130,14 @@ struct Value
class Filter : public std::function<bool(const Value&)> {
using std::function<bool(const Value&)>::function;
public:
Filter chain(Filter&& f2) {
auto f1 = *this;
return chain(std::move(f1), std::move(f2));
}
Filter chainOr(Filter&& f2) {
auto f1 = *this;
return chainOr(std::move(f1), std::move(f2));
}
static Filter chain(Filter&& f1, Filter&& f2) {
if (not f1) return f2;
if (not f2) return f1;
@@ -152,12 +160,6 @@ struct Value
return f1(v) or f2(v);
};
}
Filter chain(Filter&& f2) {
return chain(std::move(*this), std::move(f2));
}
Filter chainOr(Filter&& f2) {
return chainOr(std::move(*this), std::move(f2));
}
};
static const Filter AllFilter() {