ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
start_with.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/memory_model.hpp>
14#include <rpp/observables/constraints.hpp>
15#include <rpp/observables/details/member_overload.hpp>
16
17namespace rpp::details
18{
19struct start_with_tag;
20}
21
22namespace rpp::details
23{
24template<constraint::decayed_type Type, constraint::observable_of_type<Type> TObservable, constraint::observable_of_type<Type> ...TObservables>
25auto start_with_impl(TObservable&& observable, TObservables&&... observables_to_start_with);
26
27template<rpp::memory_model memory_model, constraint::decayed_type Type, constraint::decayed_same_as<Type> ...TTypes, constraint::observable_of_type<Type> TObservable>
28auto start_with_impl(TObservable&& observable, TTypes&& ...vals_to_start_with);
29
30template<constraint::decayed_type Type, typename SpecificObservable>
31struct member_overload<Type, SpecificObservable, start_with_tag>
32{
56 template<rpp::memory_model memory_model = memory_model::use_stack, constraint::decayed_same_as<Type> ...TTypes>
57 auto start_with(TTypes&&...vals_to_start_with) const & requires is_header_included<start_with_tag, TTypes...>
58 {
59 return start_with_impl<memory_model, Type>(*static_cast<const SpecificObservable*>(this), std::forward<TTypes>(vals_to_start_with)...);
60 }
61
62 template<rpp::memory_model memory_model = memory_model::use_stack, constraint::decayed_same_as<Type> ...TTypes>
63 auto start_with(TTypes&&...vals_to_start_with) && requires (is_header_included<start_with_tag, TTypes...>&& constraint::variadic_is_same_type<Type, TTypes...>)
64 {
65 return start_with_impl<memory_model, Type>(std::move(*static_cast<SpecificObservable*>(this)), std::forward<TTypes>(vals_to_start_with)...);
66 }
67
90 template<constraint::observable_of_type<Type> ...TObservables>
91 auto start_with(TObservables&&...observables_to_start_with) const& requires is_header_included<start_with_tag, TObservables...>
92 {
93 return start_with_impl<Type>(*static_cast<const SpecificObservable*>(this), std::forward<TObservables>(observables_to_start_with)...);
94 }
95
96 template<constraint::observable_of_type<Type> ...TObservables>
97 auto start_with(TObservables&&...observables_to_start_with) && requires is_header_included<start_with_tag, TObservables...>
98 {
99 return start_with_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)), std::forward<TObservables>(observables_to_start_with)...);
100 }
101};
102} // namespace rpp::details
Definition: member_overload.hpp:19