asio: object_server: simpilify 'callFunction'

The original implementation of this function seemed to be in a C++14
template style that is no longer necessary.  Utilizing if-constexpr and
auto the function was able to be simplified to be non-templated and
support both void/non-void returns without duplication.

Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I589e80ccc4ce673d46e6bc1a0441983a4e18c12e
diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 2f5d888..57c5de0 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -125,18 +125,14 @@
     using InputTupleType = utility::decay_tuple_t<CallbackSignature>;
     using ResultType = boost::callable_traits::return_type_t<CallbackType>;
     CallbackType func_;
-    template <typename T>
-    std::enable_if_t<!std::is_void_v<T>, void>
-        callFunction(message_t& m, InputTupleType& inputArgs)
+
+    void callFunction(message_t& m, InputTupleType& inputArgs)
     {
-        ResultType r = std::apply(func_, inputArgs);
-        m.append(r);
-    }
-    template <typename T>
-    std::enable_if_t<std::is_void_v<T>, void>
-        callFunction(message_t&, InputTupleType& inputArgs)
-    {
-        std::apply(func_, inputArgs);
+        auto r = std::apply(func_, inputArgs);
+        if constexpr (!std::is_void_v<decltype(r)>)
+        {
+            m.append(r);
+        }
     }
 
     // optional message-first-argument callback
@@ -161,7 +157,7 @@
         {
             inputArgs.emplace(dbusArgs);
         }
-        callFunction<ResultType>(ret, *inputArgs);
+        callFunction(ret, *inputArgs);
         ret.method_return();
         return 1;
     };
@@ -214,19 +210,16 @@
     using ResultType = boost::callable_traits::return_type_t<CallbackType>;
     boost::asio::io_context& io_;
     CallbackType func_;
-    template <typename T>
-    std::enable_if_t<!std::is_void_v<T>, void>
-        callFunction(message_t& m, InputTupleType& inputArgs)
+
+    void callFunction(message_t& m, InputTupleType& inputArgs)
     {
-        ResultType r = std::apply(func_, inputArgs);
-        m.append(r);
+        auto r = std::apply(func_, inputArgs);
+        if constexpr (!std::is_void_v<decltype(r)>)
+        {
+            m.append(r);
+        }
     }
-    template <typename T>
-    std::enable_if_t<std::is_void_v<T>, void>
-        callFunction(message_t&, InputTupleType& inputArgs)
-    {
-        std::apply(func_, inputArgs);
-    }
+
     // co-routine body for call
     void expandCall(boost::asio::yield_context yield, message_t& m)
     {
@@ -257,7 +250,7 @@
             inputArgs.emplace(std::tuple_cat(
                 std::forward_as_tuple(std::move(yield)), dbusArgs));
         }
-        callFunction<ResultType>(ret, *inputArgs);
+        callFunction(ret, *inputArgs);
         ret.method_return();
     };
 };