From: Radoslaw Zarzynski Date: Mon, 23 Sep 2019 15:15:47 +0000 (+0200) Subject: crimson: add support for unificating errorators into compounds. X-Git-Tag: v15.1.0~801^2~20 X-Git-Url: http://git.apps.os.sepia.ceph.com/?a=commitdiff_plain;h=c28d142356ff31fbe599650660836d3c3cdec855;p=ceph-ci.git crimson: add support for unificating errorators into compounds. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 1150161603f..8f7e2164eba 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -492,15 +492,43 @@ struct errorator { template using extend = errorator; - // comparing errorators template - struct is_carried { - static constexpr bool value = \ - ((std::is_same_v) || ...); + static constexpr bool is_carried_v = count_v > 0; + + // get a new errorator by summing and deduplicating error set of + // the errorator `unify<>` is applied on with another errorator + // provided as template parameter. + template + struct unify { + // 1st: generic NOP template + }; + template + struct unify> { + private: + // 2nd: specialization for errorators with non-empty error set. + // + // split error set of other errorator, passed as template param, + // into head and tail. Mix error set of this errorator with head + // of the other one only if it isn't already present in the set. + using step_errorator = std::conditional_t< + is_carried_v == false, + errorator, + errorator>; + using rest_errorator = errorator; + + public: + using type = typename step_errorator::template unify::type; + }; + template + struct unify> { + // 3rd: recursion finisher + static_assert(sizeof...(EmptyPack) == 0); + using type = errorator; }; - template - static constexpr bool is_carried_v = is_carried::value; + // comparing errorators template struct is_less_errorated { // NOP. @@ -599,6 +627,31 @@ public: }; // class errorator, <> specialization +template +struct compound_errorator { +private: + // generic template. Empty `FurtherErrators` are handled by + // the specialization below. + static_assert(sizeof...(FurtherErrators) > 0); + using step = + typename compound_errorator::type; + +public: + using type = + typename compound_errorator::type; +}; +template +struct compound_errorator { + // specialization for empty `FurtherErrators` arg pack + using type = + typename ErroratorOne::template unify::type; +}; +template +using compound_errorator_t = typename compound_errorator::type; + // this is conjunction of two nasty features: C++14's variable template // and inline global variable of C++17. The latter is crucial to ensure // the variable will get the same address across all translation units.