Skip to content
Snippets Groups Projects
Commit 98a3960b authored by Simon Désaulniers's avatar Simon Désaulniers
Browse files

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.
parent 92613f5f
No related branches found
No related tags found
No related merge requests found
......@@ -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() {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment