ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
switch_on_next.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - 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/observables/constraints.hpp>
14#include <rpp/observables/details/member_overload.hpp>
15
16namespace rpp::details
17{
18 struct switch_on_next_tag;
19}
20
21namespace rpp::details
22{
23template<constraint::decayed_type Type>
24struct switch_on_next_impl;
25
26template<constraint::decayed_type Type, typename SpecificObservable>
27struct member_overload<Type, SpecificObservable, switch_on_next_tag>
28{
65 template<typename ...Args>
66 auto switch_on_next() const& requires (is_header_included<switch_on_next_tag, Args...>&& rpp::constraint::observable<Type>)
67 {
68 return static_cast<const SpecificObservable*>(this)->template lift<utils::extract_observable_type_t<Type>>(switch_on_next_impl<Type>());
69 }
70
71 template<typename ...Args>
72 auto switch_on_next() && requires (is_header_included<switch_on_next_tag, Args...>&& rpp::constraint::observable<Type>)
73 {
74 return std::move(*static_cast<SpecificObservable*>(this)).template lift<utils::extract_observable_type_t<Type>>(switch_on_next_impl<Type>());
75 }
76};
77} // namespace rpp::details
Definition: constraints.hpp:19
Definition: member_overload.hpp:19
Definition: switch_on_next.hpp:89