From: Radoslaw Zarzynski Date: Fri, 20 Sep 2019 19:24:30 +0000 (+0200) Subject: crimson: deduplicate errorator's error set. X-Git-Tag: v15.1.0~801^2~21 X-Git-Url: http://git-server-git.apps.pok.os.sepia.ceph.com/?a=commitdiff_plain;h=055291fab84b0053d20a6775df8138ec2b93b0ae;p=ceph.git crimson: deduplicate errorator's error set. Signed-off-by: Radoslaw Zarzynski --- diff --git a/src/crimson/common/errorator.h b/src/crimson/common/errorator.h index 927aa20cf621..1150161603f2 100644 --- a/src/crimson/common/errorator.h +++ b/src/crimson/common/errorator.h @@ -234,6 +234,17 @@ struct errorator { static_assert((... && is_error_v), "errorator expects presence of ::is_error in all error types"); + template + struct contains_once { + static constexpr bool value = + (0 + ... + std::is_same_v) == 1; + }; + template + static constexpr bool contains_once_v = contains_once::value; + + static_assert((... && contains_once_v), + "no error type in errorator can be duplicated"); + template class future : private seastar::future { using base_t = seastar::future; @@ -268,12 +279,21 @@ struct errorator { struct make_errorator, ErrorVisitorRetsHeadT, ErrorVisitorRetsTailT...> { + private: + using step_errorator = errorator; + + public: using type = std::conditional_t< - is_error_v, + // add ErrorVisitorRetsHeadT only if 1) it's an error type and + // 2) isn't already included in the errorator's error set. + // It's enough to negate contains_once_v as any errorator<...> + // type is already guaranteed to be free of duplications. + is_error_v && + !step_errorator::template contains_once_v, typename make_errorator, ErrorVisitorRetsTailT...>::type, - typename make_errorator, + typename make_errorator::type>; }; // finish the recursion