ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
first.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
16namespace rpp::details
17{
18struct first_tag;
19}
20
21namespace rpp::details
22{
23
24template<constraint::decayed_type Type>
25struct first_impl;
26
27template<constraint::decayed_type Type, typename SpecificObservable>
28struct member_overload<Type, SpecificObservable, first_tag>
29{
62 auto first() const & requires is_header_included<first_tag, Type>
63 {
64 return cast_this()->template lift<Type>(first_impl<Type>{});
65 }
66
67 auto first() && requires is_header_included<first_tag, Type>
68 {
69 return move_this().template lift<Type>(first_impl<Type>{});
70 }
71
72private:
73 const SpecificObservable* cast_this() const
74 {
75 return static_cast<const SpecificObservable*>(this);
76 }
77
78 SpecificObservable&& move_this()
79 {
80 return std::move(*static_cast<SpecificObservable*>(this));
81 }
82};
83} // namespace rpp::details
Definition: first.hpp:44
Definition: member_overload.hpp:19