ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
multicast.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#include <rpp/subjects/constraints.hpp>
16
17namespace rpp::details
18{
19struct multicast_tag;
20}
21
22namespace rpp::details
23{
24template<constraint::decayed_type Type, constraint::observable_of_type<Type> TObs, subjects::constraint::subject_of_type<Type> TSubject>
25auto multicast_impl(TObs&& observable, TSubject&& subject);
26
27template<constraint::decayed_type Type, typename SpecificObservable>
28struct member_overload<Type, SpecificObservable, multicast_tag>
29{
44 template<subjects::constraint::subject_of_type<Type> TSubject>
45 auto multicast(TSubject&& subject) const& requires is_header_included<multicast_tag, TSubject>
46 {
47 return multicast_impl<Type>(*static_cast<const SpecificObservable*>(this), std::forward<TSubject>(subject));
48 }
49
50 template<subjects::constraint::subject_of_type<Type> TSubject>
51 auto multicast(TSubject&& subject) && requires is_header_included<multicast_tag, TSubject>
52 {
53 return multicast_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)), std::forward<TSubject>(subject));
54 }
55};
56} // namespace rpp::details
auto multicast(TSubject &&subject) const &
Converts ordinary observable to rpp::connectable_observable with help of provided subject.
Definition: multicast.hpp:45
Definition: member_overload.hpp:19