diff options
Diffstat (limited to 'brillo/dbus/dbus_method_invoker.h')
-rw-r--r-- | brillo/dbus/dbus_method_invoker.h | 26 |
1 files changed, 2 insertions, 24 deletions
diff --git a/brillo/dbus/dbus_method_invoker.h b/brillo/dbus/dbus_method_invoker.h index f3d0e6b..2a8708b 100644 --- a/brillo/dbus/dbus_method_invoker.h +++ b/brillo/dbus/dbus_method_invoker.h @@ -73,7 +73,6 @@ #include <brillo/errors/error.h> #include <brillo/errors/error_codes.h> #include <brillo/brillo_export.h> -#include <dbus/file_descriptor.h> #include <dbus/message.h> #include <dbus/object_proxy.h> @@ -141,27 +140,6 @@ inline std::unique_ptr<dbus::Response> CallMethodAndBlock( args...); } -namespace internal { -// In order to support non-copyable dbus::FileDescriptor, we have this -// internal::HackMove() helper function that does really nothing for normal -// types but uses Pass() for file descriptors so we can move them out from -// the temporaries created inside DBusParamReader<...>::Invoke(). -// If only libchrome supported real rvalues so we can just do std::move() and -// be done with it. -template <typename T> -inline const T& HackMove(const T& val) { - return val; -} - -// Even though |val| here is passed as const&, the actual value is created -// inside DBusParamReader<...>::Invoke() and is temporary in nature, so it is -// safe to move the file descriptor out of |val|. That's why we are doing -// const_cast here. It is a bit hacky, but there is no negative side effects. -inline dbus::FileDescriptor HackMove(const dbus::FileDescriptor& val) { - return std::move(const_cast<dbus::FileDescriptor&>(val)); -} -} // namespace internal - // Extracts the parameters of |ResultTypes...| types from the message reader // and puts the values in the resulting |tuple|. Returns false on error and // provides additional error details in |error| object. @@ -171,7 +149,7 @@ inline bool ExtractMessageParametersAsTuple( ErrorPtr* error, std::tuple<ResultTypes...>* val_tuple) { auto callback = [val_tuple](const ResultTypes&... params) { - *val_tuple = std::forward_as_tuple(internal::HackMove(params)...); + *val_tuple = std::forward_as_tuple(params...); }; return DBusParamReader<false, ResultTypes...>::Invoke( callback, reader, error); @@ -184,7 +162,7 @@ inline bool ExtractMessageParametersAsTuple( ErrorPtr* error, std::tuple<ResultTypes&...>* ref_tuple) { auto callback = [ref_tuple](const ResultTypes&... params) { - *ref_tuple = std::forward_as_tuple(internal::HackMove(params)...); + *ref_tuple = std::forward_as_tuple(params...); }; return DBusParamReader<false, ResultTypes...>::Invoke( callback, reader, error); |