ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
take_until.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
16namespace rpp::details
17{
18struct take_until_tag;
19}
20
21namespace rpp::details
22{
23
24template<constraint::decayed_type Type, constraint::observable TTriggerObservable>
25struct take_until_impl;
26
27template<constraint::decayed_type Type, typename SpecificObservable>
28struct member_overload<Type, SpecificObservable, take_until_tag>
29{
30
71 template<constraint::observable TTriggerObservable>
72 auto take_until(TTriggerObservable&& until_observable) const& requires is_header_included<take_until_tag, TTriggerObservable>
73 {
74 return cast_this()->template lift<Type>(take_until_impl<Type, std::decay_t<TTriggerObservable>>{std::forward<TTriggerObservable>(until_observable)});
75 }
76
77 template<constraint::observable TTriggerObservable>
78 auto take_until(TTriggerObservable&& until_observable) && requires is_header_included<take_until_tag, TTriggerObservable>
79 {
80 return move_this().template lift<Type>(take_until_impl<Type, std::decay_t<TTriggerObservable>>{std::forward<TTriggerObservable>(until_observable)});
81 }
82
83private:
84 const SpecificObservable* cast_this() const
85 {
86 return static_cast<const SpecificObservable*>(this);
87 }
88
89 SpecificObservable&& move_this()
90 {
91 return std::move(*static_cast<SpecificObservable*>(this));
92 }
93};
94
95} // namespace rpp::details
Definition: member_overload.hpp:19
"combine_latest" operator (an OperatorFn used by "lift").
Definition: take_until.hpp:61