]> git.apps.os.sepia.ceph.com Git - ceph.git/commitdiff
crimson: add more static asserts to errorator.
authorRadoslaw Zarzynski <rzarzyns@redhat.com>
Tue, 10 Sep 2019 16:21:10 +0000 (18:21 +0200)
committerRadoslaw Zarzynski <rzarzyns@redhat.com>
Wed, 20 Nov 2019 19:37:28 +0000 (20:37 +0100)
Signed-off-by: Radoslaw Zarzynski <rzarzyns@redhat.com>
src/crimson/common/errorator.h

index 19b440a6c2b59668cd6bb6705d23eb56680e157d..2f52bd8215f68a892ee63c7cf456571a9d1ffd63 100644 (file)
@@ -67,6 +67,8 @@ public:
 
   template <_impl::ct_error ErrorV>
   void operator()(const unthrowable_wrapper<ErrorV>& e) {
+    static_assert(std::is_invocable<ErrorVisitorT, decltype(e)>::value,
+                  "provided Error Visitor is not exhaustive");
     // In C++ throwing an exception isn't the sole way to signal
     // error with it. This approach nicely fits cold, infrequent cases
     // but when applied to a hot one, it will likely hurt performance.
@@ -229,6 +231,11 @@ struct errorator {
 
     template <class ValueFuncT, class ErrorVisitorT>
     auto safe_then(ValueFuncT&& valfunc, ErrorVisitorT&& errfunc) {
+      static_assert((... && std::is_invocable_v<
+                      ErrorVisitorT,
+                      decltype(WrappedAllowedErrorsT::instance)>),
+                    "provided Error Visitor is not exhaustive");
+
       using value_func_result_t = std::invoke_result_t<ValueFuncT, ValuesT&&...>;
       // recognize whether there can be any error coming from the Value
       // Function.