From 08c21069c48a0fb717618e853d94598b224866e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrien=20B=C3=A9raud?= Date: Sat, 30 Apr 2016 02:25:06 -0400 Subject: [PATCH] filters: add 'or' chaining --- include/opendht/value.h | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/include/opendht/value.h b/include/opendht/value.h index a74f93a0..4d55984e 100644 --- a/include/opendht/value.h +++ b/include/opendht/value.h @@ -146,9 +146,18 @@ struct Value return true; }; } + static Filter chainOr(Filter&& f1, Filter&& f2) { + if (not f1 or not f2) return AllFilter(); + return [f1,f2](const Value& v) { + 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() {