From 71599da8eaff3948c4871c997305686bf90848b1 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Adrien=20B=C3=A9raud?= <adrien.beraud@savoirfairelinux.com>
Date: Sat, 16 Mar 2019 14:27:23 -0400
Subject: [PATCH] value: add "not" method

---
 include/opendht/value.h | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/include/opendht/value.h b/include/opendht/value.h
index 58010f9e..9867745f 100644
--- a/include/opendht/value.h
+++ b/include/opendht/value.h
@@ -171,6 +171,13 @@ struct OPENDHT_PUBLIC Value
                 return f1(v) and f2(v);
             };
         }
+        static Filter chain(const Filter& f1, const Filter& f2) {
+            if (not f1) return f2;
+            if (not f2) return f1;
+            return [f1,f2](const Value& v) {
+                return f1(v) and f2(v);
+            };
+        }
         static Filter chainAll(std::vector<Filter>&& set) {
             if (set.empty()) return {};
             return std::bind([](const Value& v, std::vector<Filter>& s) {
@@ -189,6 +196,10 @@ struct OPENDHT_PUBLIC Value
                 return f1(v) or f2(v);
             };
         }
+        static Filter notFilter(Filter&& f) {
+            if (not f) return [](const Value&) { return false; };
+            return [f](const Value& v) { return not f(v); };
+        }
         std::vector<Sp<Value>> filter(const std::vector<Sp<Value>>& values) {
             if (not (*this))
                 return values;
-- 
GitLab