]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson/ertr: assert on invocability of func provided to safe_then() 52655/head
authorRadosław Zarzyński <rzarzyns@redhat.com>
Wed, 26 Jul 2023 10:42:45 +0000 (12:42 +0200)
committerRadosław Zarzyński <rzarzyns@redhat.com>
Wed, 26 Jul 2023 10:47:04 +0000 (12:47 +0200)
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 <rzarzyns@redhat.com>
src/crimson/common/errorator.h

index 705a9f05210ce271efde83cb49f35ac2d362eedd..c5d63d5b9c1d55252ba912359ff76241e95c656d 100644 (file)
@@ -599,7 +599,9 @@ private:
       static_assert((... && std::is_invocable_v<ErrorVisitorT,
                                                 AllowedErrors>),
                     "provided Error Visitor is not exhaustive");
-
+      static_assert(std::is_void_v<ValueT> ? std::is_invocable_v<ValueFuncT>
+                                          : std::is_invocable_v<ValueFuncT, ValueT>,
+                    "Value Func is not invocable with future's value");
       using value_func_result_t =
         typename std::conditional_t<std::is_void_v<ValueT>,
                                    std::invoke_result<ValueFuncT>,