ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
switch_map.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
12#pragma once
13
14#include <rpp/observables/constraints.hpp>
15#include <rpp/observables/details/member_overload.hpp>
16
17namespace rpp::details
18{
19struct switch_map_tag;
20}
21
22namespace rpp::details
23{
24template<typename Fn, typename Type>
26
27template<constraint::decayed_type Type, switch_map_callable<Type> Callable>
28auto switch_map_impl(auto&& observable, Callable&& callable);
29
30template<constraint::decayed_type Type, typename SpecificObservable>
31struct member_overload<Type, SpecificObservable, switch_map_tag>
32{
54 template<switch_map_callable<Type> Callable>
55 auto switch_map(Callable&& callable) const & requires is_header_included<switch_map_tag, Callable>
56 {
57 return switch_map_impl<Type>(*static_cast<const SpecificObservable*>(this), std::forward<Callable>(callable));
58 }
59
60 template<switch_map_callable<Type> Callable>
61 auto switch_map(Callable&& callable) && requires is_header_included<switch_map_tag, Callable>
62 {
63 return switch_map_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)), std::forward<Callable>(callable));
64 }
65};
66} // namespace rpp::details
Definition: constraints.hpp:19
Definition: switch_map.hpp:25
Definition: member_overload.hpp:19