ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
ref_count.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{
18struct ref_count_tag;
19}
20
21namespace rpp::details
22{
23template<constraint::decayed_type Type, constraint::observable_of_type<Type> TObs>
24auto ref_count_impl(TObs&& observable);
25
26template<constraint::decayed_type Type, typename SpecificObservable>
27struct member_overload<Type, SpecificObservable, ref_count_tag>
28{
42 template<typename ...Args>
43 auto ref_count() const& requires is_header_included<ref_count_tag, Args...>
44 {
45 return ref_count_impl<Type>(*static_cast<const SpecificObservable*>(this));
46 }
47
48 template<typename ...Args>
49 auto ref_count() && requires is_header_included<ref_count_tag, Args...>
50 {
51 return ref_count_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)));
52 }
53};
54} // namespace rpp::details
auto ref_count() const &
Forces rpp::connectable_observable to behave like common observable.
Definition: ref_count.hpp:43
Definition: member_overload.hpp:19