eina_cxx, eldbus_cxx: Fix perfect forwarding of arguments
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
This commit is contained in:
parent
7d1a27bae9
commit
f45f3e9f13
|
@ -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)...);
|
||||
}
|
||||
|
||||
} }
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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...);
|
||||
}
|
||||
|
||||
} } }
|
||||
|
|
Loading…
Reference in New Issue