From 2c8f93fb44cd08a6210f2b06d62ffb98677e7968 Mon Sep 17 00:00:00 2001 From: Vernon Mauery Date: Wed, 5 Sep 2018 12:02:39 -0700 Subject: sdbusplus::asio: fix callback with void args specialization Callbacks with no arguments failed to build due to an error in the utility::get_first_arg template. It failed to provide a type member for the void specialization. With this fix, it is possible to have a handler that has no arguments. Tested by: Added a new callback to the asio-example.cpp. Without the template change, this caused the build to fail as expected. After adding the template change, the build succeeds and the example runs as expected. Change-Id: Ib09b58c76df8cba57dc093ab37a4c1b68ea11ad3 Signed-off-by: Vernon Mauery --- example/asio-example.cpp | 7 +++++++ sdbusplus/utility/type_traits.hpp | 1 + 2 files changed, 8 insertions(+) diff --git a/example/asio-example.cpp b/example/asio-example.cpp index 31b55f2..354c7b0 100644 --- a/example/asio-example.cpp +++ b/example/asio-example.cpp @@ -17,6 +17,11 @@ int methodWithMessage(sdbusplus::message::message& m, int test) return ++test; } +int voidBar(void) +{ + return 42; +} + int main() { using GetSubTreeType = std::vectorregister_method("TestMethodWithMessage", methodWithMessage); + iface->register_method("VoidFunctionReturnsInt", voidBar); + iface->initialize(); iface->set_property("int", 45); io.run(); diff --git a/sdbusplus/utility/type_traits.hpp b/sdbusplus/utility/type_traits.hpp index fb6f0b6..2d60972 100644 --- a/sdbusplus/utility/type_traits.hpp +++ b/sdbusplus/utility/type_traits.hpp @@ -38,6 +38,7 @@ struct strip_first_arg> template struct get_first_arg { + using type = void; }; template -- cgit v1.2.3