ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
filter.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/details/member_overload.hpp>
14
15namespace rpp::details
16{
17struct filter_tag;
18}
19
20namespace rpp::details
21{
22template<constraint::decayed_type Type, std::predicate<const Type&> Predicate>
23struct filter_impl;
24
25template<constraint::decayed_type Type, typename SpecificObservable>
26struct member_overload<Type, SpecificObservable, filter_tag>
27{
59 template<std::predicate<const Type&> Predicate>
60 auto filter(Predicate&& predicate) const& requires is_header_included<filter_tag, Predicate>
61 {
62 return static_cast<const SpecificObservable*>(this)->template lift <Type>(filter_impl<Type, std::decay_t<Predicate>>{std::forward<Predicate>(predicate)});
63 }
64
65 template<std::predicate<const Type&> Predicate>
66 auto filter(Predicate&& predicate) && requires is_header_included<filter_tag, Predicate>
67 {
68 return std::move(*static_cast<SpecificObservable*>(this)).template lift<Type>(filter_impl<Type, std::decay_t<Predicate>>{std::forward<Predicate>(predicate)});
69 }
70};
71} // namespace rpp::details
Definition: filter.hpp:40
Definition: member_overload.hpp:19