[libsigc++2/variadic_bind2: 63/68] bind: Some perfect forwarding.



commit 55d0cb6144288ddafd306a5eefd3c04f4497560c
Author: Murray Cumming <murrayc murrayc com>
Date:   Fri Feb 19 11:36:56 2016 +0100

    bind: Some perfect forwarding.

 sigc++/adaptors/bind.h |   12 ++++++------
 1 files changed, 6 insertions(+), 6 deletions(-)
---
diff --git a/sigc++/adaptors/bind.h b/sigc++/adaptors/bind.h
index 980c22e..50de0ee 100644
--- a/sigc++/adaptors/bind.h
+++ b/sigc++/adaptors/bind.h
@@ -168,10 +168,10 @@ struct bind_functor : public adapts<T_functor>
 private:
   template<class T_specific, class T, std::size_t... Is>
   decltype(auto)
-  call_functor_operator_parentheses(T& tuple,
+  call_functor_operator_parentheses(T&& tuple,
     std::index_sequence<Is...>)
   {
-    return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<typename std::tuple_element<Is, 
T_specific>::type...>(std::get<Is>(tuple)...);
+    return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<typename std::tuple_element<Is, 
T_specific>::type...>(std::get<Is>(std::forward<T>(tuple))...);
   }
 };
 
@@ -194,12 +194,12 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor>
    */
   template <class... T_arg>
   decltype(auto)
-  operator()(T_arg... _A_arg)
+  operator()(T_arg&&... _A_arg)
     {
       //For instance, if _A_arg has 4 arguments,
       //we would want to call operator() with (_A_arg0, _A_arg1, _A_arg2, bound).
       
-      auto t_args = std::tuple<T_arg...>(_A_arg...);
+      auto t_args = std::tuple<T_arg...>(std::forward<T_arg>(_A_arg)...);
       auto t_bound = tuple_transform_each<internal::TransformEachInvoker>(bound_);
       auto t_with_bound = std::tuple_cat(t_args, t_bound);
 
@@ -226,10 +226,10 @@ struct bind_functor<-1, T_functor, T_type...> : public adapts<T_functor>
 private:
   template<class T_specific, class T, std::size_t... Is>
   decltype(auto)
-  call_functor_operator_parentheses(T& tuple,
+  call_functor_operator_parentheses(T&& tuple,
     std::index_sequence<Is...>)
   {
-    return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<typename std::tuple_element<Is, 
T_specific>::type...>(std::get<Is>(tuple)...);
+    return this->functor_.SIGC_WORKAROUND_OPERATOR_PARENTHESES<typename std::tuple_element<Is, 
T_specific>::type...>(std::get<Is>(std::forward<T>(tuple))...);
   }
 };
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]