ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
strategy.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/victimsnino/ReactivePlusPlus
9//
10
11#pragma once
12
13#include <rpp/observers/fwd.hpp>
14#include <rpp/sources/fwd.hpp>
15
16#include <rpp/defs.hpp>
17#include <rpp/disposables/disposable_wrapper.hpp>
18#include <rpp/observables/details/chain_strategy.hpp>
19#include <rpp/observables/observable.hpp>
20#include <rpp/utils/constraints.hpp>
21#include <rpp/utils/tuple.hpp>
22#include <rpp/utils/utils.hpp>
23
24namespace rpp::operators::details
25{
26 template<typename Operator, rpp::constraint::decayed_type... TArgs>
28 {
29 public:
30 template<rpp::constraint::decayed_same_as<TArgs>... TTArgs>
31 lift_operator(TTArgs&&... args)
32 : m_vals{std::forward<TTArgs>(args)...}
33 {
34 }
35
36 template<rpp::constraint::decayed_type Type, rpp::constraint::observer Observer>
37 auto lift(Observer&& observer) const
38 {
39 return m_vals.apply(&apply<Type, Observer, TArgs...>, std::forward<Observer>(observer));
40 }
41
42 private:
45 typename... Args>
46 static auto apply(Observer&& observer, const Args&... vals)
47 {
48 static_assert(rpp::constraint::observer_of_type<std::decay_t<Observer>, typename Operator::template operator_traits<Type>::result_type>);
49 return rpp::observer<Type, typename Operator::template operator_traits<Type>::template observer_strategy<std::decay_t<Observer>>>{std::forward<Observer>(observer), vals...}; // NOLINT
50 }
51
52 private:
53 RPP_NO_UNIQUE_ADDRESS rpp::utils::tuple<TArgs...> m_vals{};
54 };
55} // namespace rpp::operators::details
Base class for any observer used in RPP. It handles core callbacks of observers. Objects of this clas...
Definition observer.hpp:172
Definition strategy.hpp:28
Definition tuple.hpp:105
Definition constraints.hpp:22
Definition fwd.hpp:253
Definition fwd.hpp:250