ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
map.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#include <rpp/utils/function_traits.hpp>
15
16namespace rpp::details
17{
18struct map_tag;
19}
20
21namespace rpp::details
22{
23template<constraint::decayed_type Type, std::invocable<Type> Callable>
24struct map_impl;
25
26template<constraint::decayed_type Type, typename SpecificObservable>
27struct member_overload<Type, SpecificObservable, map_tag>
28{
64 template<std::invocable<Type> Callable>
65 auto map(Callable&& callable) const & requires is_header_included<map_tag, Callable>
66 {
67 return static_cast<const SpecificObservable*>(this)->template lift<utils::decayed_invoke_result_t<Callable, Type>>(map_impl<Type, std::decay_t<Callable>>{std::forward<Callable>(callable)});
68 }
69
70 template<std::invocable<Type> Callable>
71 auto map(Callable&& callable) && requires is_header_included<map_tag, Callable>
72 {
73 return std::move(*static_cast<SpecificObservable*>(this)).template lift<utils::decayed_invoke_result_t<Callable, Type>>(map_impl<Type, std::decay_t<Callable>>{std::forward<Callable>(callable)});
74 }
75};
76} // namespace rpp::details
Definition: map.hpp:40
Definition: member_overload.hpp:19