}
};
-template <class... WrappedAllowedErrorsT>
+template <class... AllowedErrors>
struct errorator {
template <class... ValuesT>
class future : private seastar::future<ValuesT...> {
struct make_errorator {
// NOP. The generic template.
};
- template <class... ValueFuncWrappedAllowedErrorsT,
+ template <class... ValueFuncAllowedErrors,
class ErrorVisitorRetsHeadT,
class... ErrorVisitorRetsTailT>
- struct make_errorator<errorator<ValueFuncWrappedAllowedErrorsT...>,
+ struct make_errorator<errorator<ValueFuncAllowedErrors...>,
ErrorVisitorRetsHeadT,
ErrorVisitorRetsTailT...> {
using type = std::conditional_t<
is_error_v<ErrorVisitorRetsHeadT>,
- typename make_errorator<errorator<ValueFuncWrappedAllowedErrorsT...,
+ typename make_errorator<errorator<ValueFuncAllowedErrors...,
ErrorVisitorRetsHeadT>,
ErrorVisitorRetsTailT...>::type,
- typename make_errorator<errorator<ValueFuncWrappedAllowedErrorsT...>,
+ typename make_errorator<errorator<ValueFuncAllowedErrors...>,
ErrorVisitorRetsTailT...>::type>;
};
// finish the recursion
- template <class... ValueFuncWrappedAllowedErrorsT>
- struct make_errorator<errorator<ValueFuncWrappedAllowedErrorsT...>> {
- using type = ::ceph::errorator<ValueFuncWrappedAllowedErrorsT...>;
+ template <class... ValueFuncAllowedErrors>
+ struct make_errorator<errorator<ValueFuncAllowedErrors...>> {
+ using type = ::crimson::errorator<ValueFuncAllowedErrors...>;
};
template <class... Args>
using make_errorator_t = typename make_errorator<Args...>::type;
using base_t::base_t;
public:
- using errorator_type = ceph::errorator<WrappedAllowedErrorsT...>;
+ using errorator_type = ::crimson::errorator<AllowedErrors...>;
[[gnu::always_inline]]
future(base_t&& base)
operator ErroratedFuture<ValuesT...> () && {
using dest_errorator_t = \
typename ErroratedFuture<ValuesT...>::errorator_type;
- using this_errorator_t = errorator<WrappedAllowedErrorsT...>;
+ using this_errorator_t = errorator<AllowedErrors...>;
static_assert(!dest_errorator_t::template is_less_errorated_v<this_errorator_t>,
"conversion is possible to more-or-eq errorated future!");
// TODO: we don't really need to `make_exception_ptr` each time. It still
// allocates memory underneath while can be replaced with single instance
// per type created on start-up.
- template <_impl::ct_error ErrorV>
- future(const unthrowable_wrapper<ErrorV>& e)
- : base_t(seastar::make_exception_future<ValuesT...>(exception<std::decay_t<decltype(e)>>{})) {
- // this is `fold expression` of C++17
- static_assert((... || (std::is_same_v<std::decay_t<decltype(e)>,
- WrappedAllowedErrorsT>)),
- "disallowed ct_error");
+ template <class ErrorT,
+ class DecayedT = std::decay_t<ErrorT>,
+ bool IsError = is_error_v<DecayedT>,
+ class = std::enable_if_t<IsError>>
+ future(ErrorT&&)
+ : base_t(seastar::make_exception_future<ValuesT...>(exception<DecayedT>{})) {
+ // this is `fold expression` of C++17.
+ static_assert((... || (std::is_same_v<DecayedT, AllowedErrors>)),
+ "ErrorT is not enlisted in errorator");
}
template <class ValueFuncT, class ErrorVisitorT>
auto safe_then(ValueFuncT&& valfunc, ErrorVisitorT&& errfunc) {
static_assert((... && std::is_invocable_v<ErrorVisitorT,
- WrappedAllowedErrorsT>),
+ AllowedErrors>),
"provided Error Visitor is not exhaustive");
using value_func_result_t = std::invoke_result_t<ValueFuncT, ValuesT&&...>;
// to next continuation.
using return_errorator_t = make_errorator_t<
value_func_errorator_t,
- std::decay_t<std::invoke_result_t<
- ErrorVisitorT, WrappedAllowedErrorsT>>...>;
+ std::decay_t<std::invoke_result_t<ErrorVisitorT, AllowedErrors>>...>;
// OK, now we know about all errors next continuation must take
// care about. If Visitor handled everything and the Value Func
// doesn't return any, we'll finish with errorator<>::future
std::forward<ErrorVisitorT>(errfunc),
std::move(future).get_exception()
);
- (maybe_handle_error.template handle<WrappedAllowedErrorsT>() , ...);
+ (maybe_handle_error.template handle<AllowedErrors>() , ...);
return plainify(std::move(maybe_handle_error).get_result());
} else {
return plainify(futurator_t::apply(std::forward<ValueFuncT>(valfunc),
private:
// for the sake of `plainify()` let any errorator convert errorated
// future into plain one.
- template <class... AnyWrappedAllowedErrorsT>
+ template <class...>
friend class errorator;
base_t&& as_plain_future() && {
template <class ErrorT>
decltype(auto) operator()(ErrorT&& e) {
using decayed_t = std::decay_t<ErrorT>;
- static_assert((... || std::is_same_v<WrappedAllowedErrorsT, decayed_t>),
+ static_assert((... || std::is_same_v<AllowedErrors, decayed_t>),
"passing further disallowed ErrorT");
return std::forward<ErrorT>(e);
}
struct discard_all {
template <class ErrorT>
decltype(auto) operator()(ErrorT&&) {
- static_assert((... || std::is_same_v<WrappedAllowedErrorsT,
+ static_assert((... || std::is_same_v<AllowedErrors,
std::decay_t<ErrorT>>),
"discarding disallowed ErrorT");
return ignore_marker_t{};
};
// get a new errorator by extending current one with new error
- template <class... NewWrappedAllowedErrorsT>
- using extend = errorator<WrappedAllowedErrorsT...,
- NewWrappedAllowedErrorsT...>;
+ template <class... NewAllowedErrorsT>
+ using extend = errorator<AllowedErrors..., NewAllowedErrorsT...>;
// comparing errorators
template <class ErrorT>
struct is_carried {
static constexpr bool value = \
- ((std::is_same_v<WrappedAllowedErrorsT, ErrorT>) || ...);
+ ((std::is_same_v<AllowedErrors, ErrorT>) || ...);
};
template <class ErrorT>
static constexpr bool is_carried_v = is_carried<ErrorT>::value;
struct is_less_errorated {
// NOP.
};
- template <class... OtherWrappedAllowedErrorsT>
- struct is_less_errorated<errorator<OtherWrappedAllowedErrorsT...>> {
+ template <class... OtherAllowedErrors>
+ struct is_less_errorated<errorator<OtherAllowedErrors...>> {
static constexpr bool value = \
- ((!is_carried_v<OtherWrappedAllowedErrorsT>) || ...);
+ ((!is_carried_v<OtherAllowedErrors>) || ...);
};
template <class OtherErrorator>
static constexpr bool is_less_errorated_v = \
std::void_t<
typename ErroratedFutureT<ValuesT...>::errorator_type>> {
public:
- using type = ::ceph::errorator<WrappedAllowedErrorsT...>::future<ValuesT...>;
+ using type = ::crimson::errorator<AllowedErrors...>::future<ValuesT...>;
template <class Func, class... Args>
static type apply(Func&& func, std::tuple<Args...>&& args) {