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