ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
buffer.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2022 - present.
4// TC Wang 2022 - present.
5// Distributed under the Boost Software License, Version 1.0.
6// (See accompanying file LICENSE_1_0.txt or copy at
7// https://www.boost.org/LICENSE_1_0.txt)
8//
9// Project home: https://github.com/victimsnino/ReactivePlusPlus
10//
11
12#pragma once
13
14#include <rpp/observables/details/member_overload.hpp>
15
16#include <vector>
17
18namespace rpp::details
19{
20struct buffer_tag;
21}
22
23namespace rpp::details
24{
25template<constraint::decayed_type Type>
26using buffer_bundle_type = std::vector<Type>;
27
28template<constraint::decayed_type Type>
29struct buffer_impl;
30
31template<constraint::decayed_type Type, typename SpecificObservable>
32struct member_overload<Type, SpecificObservable, buffer_tag>
33{
66 template<typename ...Args>
67 auto buffer(size_t count) const & requires is_header_included<buffer_tag, Args...>
68 {
69 return CastThis()->template lift<buffer_bundle_type<Type>>(buffer_impl<Type>{count});
70 }
71
72 template<typename ...Args>
73 auto buffer(size_t count) && requires is_header_included<buffer_tag, Args...>
74 {
75 return MoveThis().template lift<buffer_bundle_type<Type>>(buffer_impl<Type>{count});
76 }
77
78private:
79 const SpecificObservable* CastThis() const
80 {
81 return static_cast<const SpecificObservable*>(this);
82 }
83
84 SpecificObservable&& MoveThis()
85 {
86 return std::move(*static_cast<SpecificObservable*>(this));
87 }
88};
89} // namespace rpp::details
Definition: buffer.hpp:82
Definition: member_overload.hpp:19