ReactivePlusPlus
One more implementation of ReactiveX approach in C++ with care about performance and templates in mind
 
Loading...
Searching...
No Matches
constraints.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/subscribers/fwd.hpp>
14
15#include <type_traits>
16
17namespace rpp::constraint
18{
19template<typename T> concept subscriber = std::is_base_of_v<details::subscriber_tag, std::decay_t<T>> && observer_callbacks_exists<T>;
20}
21
22namespace rpp::utils
23{
24namespace details
25{
26 template<rpp::constraint::subscriber T>
28 {
29 template<typename TT>
30 static TT deduce(const rpp::details::typed_subscriber_tag<TT>&);
31
32 using type = decltype(deduce(std::declval<std::decay_t<T>>()));
33 };
34} // namespace details
35
36template<rpp::constraint::subscriber T>
37using extract_subscriber_type_t = typename details::extract_subscriber_type<T>::type;
38} // namespace rpp::utils
39
40namespace rpp::constraint
41{
42template<typename T, typename Type> concept subscriber_of_type = subscriber<T> && std::same_as<utils::extract_subscriber_type_t<T>, Type> && observer_on_next_exists<T, Type>;
43} // namespace rpp::constraint
Definition: constraints.hpp:19
Definition: constraints.hpp:50
Definition: constraints.hpp:42
Definition: constraints.hpp:19
Definition: constraints.hpp:28