From e0538ca63bf3b9ebb45baf1bd3e7ed2af8926f6b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Rados=C5=82aw=20Zarzy=C5=84ski?= Date: Wed, 26 Jul 2023 12:42:45 +0200 Subject: [PATCH] crimson/ertr: assert on invocability of func provided to safe_then() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit The goal is to fail with an easier-to-understand error on failed `static_assert()` than cryptic template substitution errors when the function provided to e.g. `safe_then()` doesn't match the type carried within an errorated future. Signed-off-by: Radosław Zarzyński (cherry picked from commit 83687f2cc86897d60a460575a7ab2acbd2f9170c) --- src/crimson/common/errorator.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 705a9f05210ce..c5d63d5b9c1d5 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -599,7 +599,9 @@ private: static_assert((... && std::is_invocable_v), "provided Error Visitor is not exhaustive"); - + static_assert(std::is_void_v ? std::is_invocable_v + : std::is_invocable_v, + "Value Func is not invocable with future's value"); using value_func_result_t = typename std::conditional_t, std::invoke_result, -- 2.47.3