ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
concat.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> // constraint::observable_of_type
14#include <rpp/observables/details/member_overload.hpp> // member_overload
15
16
17namespace rpp::details
18{
19struct concat_tag;
20}
21
22namespace rpp::details
23{
24template<constraint::decayed_type Type>
25struct concat_impl;
26
27template<constraint::decayed_type Type, constraint::observable_of_type<Type> ... TObservables>
28auto concat_with_impl(TObservables&&... observables);
29
30template<constraint::decayed_type Type, typename SpecificObservable>
31struct member_overload<Type, SpecificObservable, concat_tag>
32{
70 template<typename ...Args>
71 auto concat() const& requires (is_header_included<concat_tag, Args...>&& rpp::constraint::observable<Type>)
72 {
73 return static_cast<const SpecificObservable*>(this)->template lift<utils::extract_observable_type_t<Type>>(concat_impl<Type>{});
74 }
75
76 template<typename ...Args>
77 auto concat() && requires (is_header_included<concat_tag, Args...>&& rpp::constraint::observable<Type>)
78 {
79 return std::move(*static_cast<SpecificObservable*>(this)).template lift<utils::extract_observable_type_t<Type>>(concat_impl<Type>{});
80 }
81
116 template<constraint::observable_of_type<Type> ...TObservables>
117 auto concat_with(TObservables&&... observables) const& requires (is_header_included<concat_tag, TObservables...> && sizeof...(TObservables) >= 1)
118 {
119 return concat_with_impl<Type>(static_cast<const SpecificObservable*>(this)->as_dynamic(), std::forward<TObservables>(observables).as_dynamic()...);
120 }
121
122 template<constraint::observable_of_type<Type> ...TObservables>
123 auto concat_with(TObservables&&... observables) && requires (is_header_included<concat_tag, TObservables...> && sizeof...(TObservables) >= 1)
124 {
125 return concat_with_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)).as_dynamic(), std::forward<TObservables>(observables).as_dynamic()...);
126 }
127};
128} // namespace rpp::details
Definition: constraints.hpp:19
Definition: concat.hpp:128
Definition: member_overload.hpp:19