ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
on_error_resume_next.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - present.
4// TC Wang 2022 - present.
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// https://www.boost.org/LICENSE_1_0.txt)
8//
9// Project home: https://github.com/victimsnino/ReactivePlusPlus
10
11#pragma once
12
13#include <rpp/observables/constraints.hpp>
14#include <rpp/observables/details/member_overload.hpp>
15#include <rpp/utils/exceptions.hpp>
16#include <rpp/utils/function_traits.hpp>
17
18#include <exception>
19
20namespace rpp::details
21{
22struct on_error_resume_next_tag;
23}
24
25namespace rpp::details
26{
27
28template<typename Fn>
30
31template<constraint::decayed_type Type, rpp::details::resume_callable ResumeCallable>
32struct on_error_resume_next_impl;
33
34template<constraint::decayed_type Type, typename SpecificObservable>
35struct member_overload<Type, SpecificObservable, on_error_resume_next_tag>
36{
37
73 template<rpp::details::resume_callable ResumeCallable>
74 auto on_error_resume_next(ResumeCallable&& resume_callable) const& requires is_header_included<on_error_resume_next_tag, ResumeCallable>
75 {
76 return cast_this()->template lift<Type>(on_error_resume_next_impl<Type, std::decay_t<ResumeCallable>>{std::forward<ResumeCallable>(resume_callable)});
77 }
78
79 template<rpp::details::resume_callable ResumeCallable>
80 auto on_error_resume_next(ResumeCallable&& resume_callable) && requires is_header_included<on_error_resume_next_tag, ResumeCallable>
81 {
82 return move_this().template lift<Type>(on_error_resume_next_impl<Type, std::decay_t<ResumeCallable>>{std::forward<ResumeCallable>(resume_callable)});
83 }
84
85private:
86 const SpecificObservable* cast_this() const
87 {
88 return static_cast<const SpecificObservable*>(this);
89 }
90
91 SpecificObservable&& move_this()
92 {
93 return std::move(*static_cast<SpecificObservable*>(this));
94 }
95};
96
97} // namespace rpp::details
Definition: constraints.hpp:19
Definition: on_error_resume_next.hpp:29
Definition: member_overload.hpp:19
Functor of OperatorFn for "on_error_resume_next" operator (used by "lift").
Definition: on_error_resume_next.hpp:45