ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
repeat.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 repeat_tag;
19}
20
21namespace rpp::details
22{
23template<constraint::decayed_type Type, constraint::observable_of_type<Type> TObs>
24auto repeat_impl(TObs&& observable, size_t count);
25
26template<constraint::decayed_type Type, constraint::observable_of_type<Type> TObs>
27auto repeat_impl(TObs&& observable);
28
29template<constraint::decayed_type Type, typename SpecificObservable>
30struct member_overload<Type, SpecificObservable, repeat_tag>
31{
67 template<typename...Args>
68 auto repeat(size_t count) const& requires is_header_included<repeat_tag, Args...>
69 {
70 return repeat_impl<Type>(*static_cast<const SpecificObservable*>(this), count);
71 }
72
73 template<typename...Args>
74 auto repeat(size_t count) && requires is_header_included<repeat_tag, Args...>
75 {
76 return repeat_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)), count);
77 }
78
97 template<typename...Args>
98 auto repeat() const& requires is_header_included<repeat_tag, Args...>
99 {
100 return repeat_impl<Type>(*static_cast<const SpecificObservable*>(this));
101 }
102
103 template<typename...Args>
104 auto repeat() && requires is_header_included<repeat_tag, Args...>
105 {
106 return repeat_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)));
107 }
108};
109} // namespace rpp::details
Definition: member_overload.hpp:19