From: Radoslaw Zarzynski Date: Thu, 21 May 2020 21:13:21 +0000 (+0200) Subject: crimson/common: extend errorator with assert_all{}. X-Git-Tag: v16.1.0~2245^2~2 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=89feb434552745387ebd59ef7a6eb40cee4c3255;p=ceph.git crimson/common: extend errorator with assert_all{}. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index b7a7c8eff003..ea68e351ec2c 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -8,6 +8,8 @@ #include +#include "include/ceph_assert.h" + namespace crimson { template @@ -728,6 +730,28 @@ public: } }; + // assert_all{ "TODO" }; + class assert_all { + const char* const msg = nullptr; + public: + template + assert_all(const char (&msg)[N]) + : msg(msg) { + } + assert_all() = default; + + template ...> + void operator()(ErrorT&&) { + static_assert(contains_once_v>, + "discarding disallowed ErrorT"); + if (msg) { + ceph_abort(msg); + } else { + ceph_abort(); + } + } + }; + template static decltype(auto) all_same_way(ErrorFunc&& error_func) { return all_same_way_t{std::forward(error_func)}; @@ -951,6 +975,25 @@ namespace ct_error { } }; + class assert_all { + const char* const msg = nullptr; + public: + template + assert_all(const char (&msg)[N]) + : msg(msg) { + } + assert_all() = default; + + template + void operator()(ErrorT&&) { + if (msg) { + ceph_abort(msg); + } else { + ceph_abort(); + } + } + }; + template static decltype(auto) all_same_way(ErrorFunc&& error_func) { return [