ReactivePlusPlus
ReactiveX implementation for C++20
Toggle main menu visibility
Loading...
Searching...
No Matches
finally.hpp
1
// ReactivePlusPlus library
2
//
3
// Copyright Aleksey Loginov 2023 - present.
4
// Distributed under the Boost Software License, Version 1.0.
5
// (See accompanying file LICENSE_1_0.txt or copy at
6
// https://www.boost.org/LICENSE_1_0.txt)
7
//
8
// Project home: https://github.com/AlexInLog/ReactivePlusPlus
9
//
10
11
#pragma once
12
13
#include <rpp/operators/fwd.hpp>
14
15
#include <rpp/defs.hpp>
16
#include <rpp/operators/details/strategy.hpp>
17
18
namespace
rpp::operators::details
19
{
20
template
<rpp::constra
int
::decayed_type LastFn>
21
struct
finally_t
22
{
23
template
<rpp::constra
int
::decayed_type T>
24
struct
operator_traits
25
{
26
using
result_type = T;
27
};
28
29
template
<rpp::details::observables::constra
int
::disposables_strategy Prev>
30
using
updated_optimal_disposables_strategy =
typename
Prev::template add<1>;
31
32
RPP_NO_UNIQUE_ADDRESS LastFn last_fn;
33
34
template
<rpp::constra
int
::decayed_type Type, rpp::constra
int
::observer Observer>
35
auto
lift(Observer&&
observer
)
const
36
{
37
observer
.
set_upstream
(make_callback_disposable(last_fn));
38
return
std::forward<Observer>(
observer
);
39
}
40
};
41
}
// namespace rpp::operators::details
42
43
namespace
rpp::operators
44
{
56
template
<rpp::constra
int
::is_nothrow_invocable LastFn>
57
auto
finally
(LastFn&& last_fn)
58
{
59
return
details::finally_t<std::decay_t<LastFn>
>{std::forward<LastFn>(last_fn)};
60
}
61
}
// namespace rpp::operators
rpp::details::observer_impl::set_upstream
void set_upstream(const disposable_wrapper &d) noexcept
Observable calls this method to pass disposable. Observer disposes this disposable WHEN observer want...
Definition
observer.hpp:49
rpp::observer
Base class for any observer used in RPP. It handles core callbacks of observers. Objects of this clas...
Definition
observer.hpp:172
rpp::operators::details::finally_t::operator_traits
Definition
finally.hpp:25
rpp::operators::details::finally_t
Definition
finally.hpp:22
src
rpp
rpp
operators
finally.hpp
Generated by
1.17.0