14#include <rpp/operators/lift.hpp>
15#include <rpp/operators/take_last.hpp>
16#include <rpp/operators/fwd/last.hpp>
17#include <rpp/operators/details/subscriber_with_state.hpp>
18#include <rpp/subscribers/constraints.hpp>
19#include <rpp/utils/exceptions.hpp>
20#include <rpp/utils/functors.hpp>
22IMPLEMENTATION_FILE(last_tag);
26template<constra
int::decayed_type Type>
42 template<constra
int::decayed_type Type>
46 auto&& last_value = state.items.at(0);
47 if (!last_value.has_value())
49 subscriber.on_error(std::make_exception_ptr(utils::not_enough_emissions{
"last() operator expects at least one emission from observable before completion"}));
53 subscriber.on_next(std::move(last_value.value()));
54 subscriber.on_completed();
58template<constra
int::decayed_type Type>
62 template<constra
int::subscriber_of_type<Type> TSub>
63 auto operator()(TSub&& subscriber)
const
65 auto subscription = subscriber.get_subscription();
67 return create_subscriber_with_dynamic_state<Type>(std::move(subscription),
69 utils::forwarding_on_error{},
71 std::forward<TSub>(subscriber),
Definition: constraints.hpp:19
Definition: take_last.hpp:42
Definition: take_last.hpp:28