asio: object_server: fix 'callFunction' for void result
`auto r = ...` doesn't work when the expression returns a void.
Improve the 'callFunction' functions to handle the void result case
by putting the `m.append` into a separate constexpr-if.
Fixes eb6a9d0.
Signed-off-by: Patrick Williams <patrick@stwcx.xyz>
Change-Id: I31dfc23d123000c62efe6243b374ba65fc0d5abd
diff --git a/include/sdbusplus/asio/object_server.hpp b/include/sdbusplus/asio/object_server.hpp
index 57c5de0..d34c96a 100644
--- a/include/sdbusplus/asio/object_server.hpp
+++ b/include/sdbusplus/asio/object_server.hpp
@@ -128,9 +128,13 @@
void callFunction(message_t& m, InputTupleType& inputArgs)
{
- auto r = std::apply(func_, inputArgs);
- if constexpr (!std::is_void_v<decltype(r)>)
+ if constexpr (std::is_void_v<ResultType>)
{
+ std::apply(func_, inputArgs);
+ }
+ else
+ {
+ auto r = std::apply(func_, inputArgs);
m.append(r);
}
}
@@ -213,9 +217,13 @@
void callFunction(message_t& m, InputTupleType& inputArgs)
{
- auto r = std::apply(func_, inputArgs);
- if constexpr (!std::is_void_v<decltype(r)>)
+ if constexpr (std::is_void_v<ResultType>)
{
+ std::apply(func_, inputArgs);
+ }
+ else
+ {
+ auto r = std::apply(func_, inputArgs);
m.append(r);
}
}