From 15bea958832a7dcfa6ac5a7f0fe1bfcf1a86b16a Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Fri, 19 Mar 2021 08:31:33 +0000 Subject: [PATCH] crimson/common: stateful_error_t allows for void-taking handlers. Before this commit there was an inconsistencty between `unthrowable_wrapper::handle()` and `stateful_error_t::handle()` in the regard of parameters the provided handler had to accept. The former was fine with void-taking handlers while the latter was not. Signed-off-by: Radoslaw Zarzynski --- src/crimson/common/errorator.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 7fd05374084..058f9fe8c64 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -190,14 +190,17 @@ struct stateful_error_t : error_t> { template static auto handle(Func&& func) { - static_assert(std::is_invocable_v); return [ func = std::forward(func) ] (stateful_error_t&& e) mutable -> decltype(auto) { try { std::rethrow_exception(e.ep); } catch (const ErrorT& obj) { - return std::invoke(std::forward(func), obj); + if constexpr (std::is_invocable_v) { + return std::invoke(std::forward(func), obj); + } else { + return std::invoke(std::forward(func)); + } } ceph_abort_msg("exception type mismatch – impossible!"); }; -- 2.39.5