From 98a3960bf8fa315d786b9fc688c3d43332b12410 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Simon=20D=C3=A9saulniers?= <sim.desaulniers@gmail.com>
Date: Thu, 5 May 2016 16:28:02 -0400
Subject: [PATCH] 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.
---
 include/opendht/value.h | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/include/opendht/value.h b/include/opendht/value.h
index 30ddf551..26f17bbd 100644
--- a/include/opendht/value.h
+++ b/include/opendht/value.h
@@ -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() {
-- 
GitLab