asio: Allow mutable lambdas + small cleanup

There are many cases in which we want to have a mutable
capture so that the lambda takes over the parameter and
we can modify it after the async callback. By making the
top level lambda mutable, the users callback can be mutable.

Also remove a couple references to experimental and a copy
that I saw when I was fixing this issue.

Tested: Added test and made sure that refish which uses
many async_method_calls still worked fine

Change-Id: Ifb1f9d8b9217187799e2defe429e76a937297ca1
Signed-off-by: James Feist <james.feist@linux.intel.com>
diff --git a/sdbusplus/asio/connection.hpp b/sdbusplus/asio/connection.hpp
index 083bfdf..4c447f8 100644
--- a/sdbusplus/asio/connection.hpp
+++ b/sdbusplus/asio/connection.hpp
@@ -25,12 +25,12 @@
 #include <boost/asio/spawn.hpp>
 #include <boost/callable_traits.hpp>
 #include <chrono>
-#include <experimental/tuple>
 #include <sdbusplus/asio/detail/async_send_handler.hpp>
 #include <sdbusplus/message.hpp>
 #include <sdbusplus/utility/read_into_tuple.hpp>
 #include <sdbusplus/utility/type_traits.hpp>
 #include <string>
+#include <tuple>
 
 namespace sdbusplus
 {
@@ -115,7 +115,7 @@
      *          complete.
      */
     template <typename MessageHandler, typename... InputArgs>
-    void async_method_call(MessageHandler handler, const std::string& service,
+    void async_method_call(MessageHandler&& handler, const std::string& service,
                            const std::string& objpath,
                            const std::string& interf, const std::string& method,
                            const InputArgs&... a)
@@ -123,8 +123,9 @@
         message::message m = new_method_call(service.c_str(), objpath.c_str(),
                                              interf.c_str(), method.c_str());
         m.append(a...);
-        async_send(m, [handler](boost::system::error_code ec,
-                                message::message& r) {
+        async_send(m, [handler = std::forward<MessageHandler>(handler)](
+                          boost::system::error_code ec,
+                          message::message& r) mutable {
             using FunctionTuple =
                 boost::callable_traits::args_t<MessageHandler>;
             using UnpackType = typename utility::strip_first_arg<
@@ -146,7 +147,7 @@
             // Note.  Callback is called whether or not the unpack was
             // successful to allow the user to implement their own handling
             auto response = std::tuple_cat(std::make_tuple(ec), responseData);
-            std::experimental::apply(handler, response);
+            std::apply(handler, response);
         });
     }