eina_cxx, eldbus_cxx: Fix perfect forwarding of arguments
authorVitor Sousa <vitorsousasilva@gmail.com>
Fri, 22 May 2015 09:31:18 +0000 (10:31 +0100)
committerDaniel Kolesa <d.kolesa@osg.samsung.com>
Fri, 22 May 2015 09:31:18 +0000 (10:31 +0100)
Summary:
Changed some std::move clauses to std::forward<Type> in order to allow
perfect forwarding.

@fix

Reviewers: felipealmeida, JackDanielZ, tasn, q66

Reviewed By: q66

Subscribers: cedric

Differential Revision: https://phab.enlightenment.org/D2508

src/bindings/eina_cxx/eina_tuple_unwrap.hh
src/bindings/eldbus_cxx/eldbus_basic.hh
src/bindings/eldbus_cxx/eldbus_freedesktop.hh
src/bindings/eldbus_cxx/eldbus_proxy_call.hh

index 379f492..f2bbb00 100644 (file)
@@ -18,9 +18,9 @@ template <typename Callable, typename T, std::size_t... S
 auto call_tuple_unwrap_prefix(Callable const& callable, T const& tuple
                               , eina::index_sequence<S...>
                               , Args&&... args)
-  -> decltype(callable(std::move(args)..., std::get<S>(tuple)...))
+  -> decltype(callable(std::forward<Args>(args)..., std::get<S>(tuple)...))
 {
-  return callable(std::move(args)..., std::get<S>(tuple)...);
+  return callable(std::forward<Args>(args)..., std::get<S>(tuple)...);
 }
 
 template <typename Callable, typename T, std::size_t... S
@@ -28,9 +28,9 @@ template <typename Callable, typename T, std::size_t... S
 auto call_tuple_unwrap_suffix(Callable const& callable, T const& tuple
                               , eina::index_sequence<S...>
                               , Args&&... args)
-  -> decltype(callable(std::get<S>(tuple)..., std::move(args)...))
+  -> decltype(callable(std::get<S>(tuple)..., std::forward<Args>(args)...))
 {
-  return callable(std::get<S>(tuple)..., std::move(args)...);
+  return callable(std::get<S>(tuple)..., std::forward<Args>(args)...);
 }
 
 } }
index 8dc3751..aa287b4 100644 (file)
@@ -43,13 +43,13 @@ struct proxy
   template <typename R, typename Callback, typename... Args>
   void call(const char* method, double timeout, Callback&& callback, Args... args) const
   {
-    eldbus::_detail::proxy_call<R>(_proxy, method, timeout, std::move(callback), args...);
+    eldbus::_detail::proxy_call<R>(_proxy, method, timeout, std::forward<Callback>(callback), args...);
   }
 
   template <typename Callback, typename... Args>
   void call(const char* method, double timeout, Callback&& callback, Args... args) const
   {
-    eldbus::_detail::proxy_call<void>(_proxy, method, timeout, std::move(callback), args...);
+    eldbus::_detail::proxy_call<void>(_proxy, method, timeout, std::forward<Callback>(callback), args...);
   }
 
   native_handle_type native_handle() { return _proxy; }
index 7bd39f9..e44b9b2 100644 (file)
@@ -61,7 +61,7 @@ void _free_cb(void* data, const void*)
 template <typename... Ins, typename F>
 pending name_request(connection& c, const char* bus, unsigned int flags, F&& function)
 {
-  F* f = new F(std::move(function));
+  F* f = new F(std::forward<F>(function));
   pending r = ::eldbus_name_request(c.native_handle(), bus, flags
                                     , &_detail::_callback_wrapper<F, Ins...>, f);
   eldbus_pending_free_cb_add(r.native_handle(), &_detail::_free_cb<F>, f);
index 9f1ddd8..f06f71a 100644 (file)
@@ -74,7 +74,7 @@ void proxy_call_impl2(Eldbus_Proxy* proxy, const char* method, double timeout
   _detail::init_signature_array<Args...>
     (signature, eina::make_index_sequence<signature_size<tuple_args>::value +1>());
 
-  Callback* c = new Callback(std::move(callback));
+  Callback* c = new Callback(std::forward<Callback>(callback));
 
   eldbus_proxy_call(proxy, method, &_on_call<R, Callback>, c, timeout, signature
                     , _detail::to_raw(args)...);
@@ -85,7 +85,7 @@ void proxy_call_impl(tag<R>, Eldbus_Proxy* proxy, const char* method, double tim
                      , Callback&& callback, Args const&... args)
 {
   typedef std::tuple<R> reply_tuple;
-  _detail::proxy_call_impl2<reply_tuple>(proxy, method, timeout, std::move(callback), args...);
+  _detail::proxy_call_impl2<reply_tuple>(proxy, method, timeout, std::forward<Callback>(callback), args...);
 }
 
 template <typename... R, typename Callback, typename... Args>
@@ -93,7 +93,7 @@ void proxy_call_impl(tag<std::tuple<R...> >, Eldbus_Proxy* proxy, const char* me
                      , Callback&& callback, Args const&... args)
 {
   typedef std::tuple<R...> reply_tuple;
-  _detail::proxy_call_impl2<reply_tuple>(proxy, method, timeout, std::move(callback), args...);
+  _detail::proxy_call_impl2<reply_tuple>(proxy, method, timeout, std::forward<Callback>(callback), args...);
 }
 
 template <typename Callback, typename... Args>
@@ -101,14 +101,14 @@ void proxy_call_impl(tag<void>, Eldbus_Proxy* proxy, const char* method, double
                      , Callback&& callback, Args const&... args)
 {
   typedef std::tuple<> reply_tuple;
-  _detail::proxy_call_impl2<reply_tuple>(proxy, method, timeout, std::move(callback), args...);
+  _detail::proxy_call_impl2<reply_tuple>(proxy, method, timeout, std::forward<Callback>(callback), args...);
 }
 
 template <typename R, typename Callback, typename... Args>
 void proxy_call(Eldbus_Proxy* proxy, const char* method, double timeout
                 , Callback&& callback, Args const&... args)
 {
-  return proxy_call_impl(tag<R>(), proxy, method, timeout, std::move(callback), args...);
+  return proxy_call_impl(tag<R>(), proxy, method, timeout, std::forward<Callback>(callback), args...);
 }
 
 } } }