From de325ade55e23856439d30abda4b0205252dda66 Mon Sep 17 00:00:00 2001 From: Radoslaw Zarzynski Date: Sun, 15 Sep 2019 17:17:45 +0200 Subject: [PATCH] crimson: introduce all_same_way() to errorator. Signed-off-by: Radoslaw Zarzynski --- src/crimson/common/errorator.h | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 55710106341f..0cc06ea1887e 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -412,6 +412,18 @@ struct errorator { } }; + template + static decltype(auto) all_same_way(ErrorFunc&& error_func) { + return [ + error_func = std::forward(error_func) + ] (auto&& e) mutable -> decltype(auto) { + using decayed_t = std::decay_t; + auto&& handler = + decayed_t::error_t::handle(std::forward(error_func)); + return std::invoke(std::move(handler), std::forward(e)); + }; + }; + // get a new errorator by extending current one with new error template using extend = errorator; -- 2.47.3