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