ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
flat_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/constraints.hpp> // constraint::observable
14#include <rpp/observables/details/member_overload.hpp> // member_overload
15#include <rpp/utils/function_traits.hpp> // decayed_invoke_result_t
16
17namespace rpp::details
18{
19struct flat_map_tag;
20}
21
22namespace rpp::details
23{
24template<typename Fn, typename Type>
26
27template<constraint::decayed_type Type, flat_map_callable<Type> Callable>
28auto flat_map_impl(auto&& observable, Callable&& callable);
29
30template<constraint::decayed_type Type, typename SpecificObservable>
31struct member_overload<Type, SpecificObservable, flat_map_tag>
32{
56 template<flat_map_callable<Type> Callable>
57 auto flat_map(Callable&& callable) const & requires is_header_included<flat_map_tag, Callable>
58 {
59 return flat_map_impl<Type>(*static_cast<const SpecificObservable*>(this), std::forward<Callable>(callable));
60 }
61
62 template<flat_map_callable<Type> Callable>
63 auto flat_map(Callable&& callable) && requires is_header_included<flat_map_tag, Callable>
64 {
65 return flat_map_impl<Type>(std::move(*static_cast<SpecificObservable*>(this)), std::forward<Callable>(callable));
66 }
67};
68} // namespace rpp::details
Definition: constraints.hpp:19
Definition: flat_map.hpp:25
Definition: member_overload.hpp:19