ReactivePlusPlus
ReactiveX implementation for C++20
Loading...
Searching...
No Matches
functors.hpp
1// ReactivePlusPlus library
2//
3// Copyright Aleksey Loginov 2023 - 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 <exception>
14#include <tuple>
15
16namespace rpp::utils
17{
18 template<class... Ts>
19 struct overloaded : Ts...
20 {
21 using Ts::operator()...;
22 };
23 template<class... Ts>
24 overloaded(Ts...) -> overloaded<Ts...>;
25
26 template<typename... Types>
28 {
29 constexpr void operator()(const Types&...) const noexcept {}
30 };
31
32 template<typename... Types>
33 void empty_function(const Types&...)
34 {
35 }
36
38 {
39 template<typename... Types>
40 constexpr void operator()(const Types&...) const noexcept
41 {
42 }
43 };
44
46 {
47 template<typename... Types>
48 constexpr void operator()(Types...) const noexcept
49 {
50 }
51 };
52
54 {
55 [[noreturn]] void operator()(const std::exception_ptr& err) const noexcept { std::rethrow_exception(err); }
56 };
57
58 struct equal_to
59 {
60 template<typename T>
61 bool operator()(const T& l, const T& r) const
62 {
63 return l == r;
64 }
65 };
66
68 {
69 bool operator()() const { return true; }
70 };
71
72 struct less
73 {
74 template<typename T>
75 bool operator()(const T& l, const T& r) const
76 {
77 return l < r;
78 }
79 };
80
82 {
83 auto operator()(auto&&... vals) const { return std::make_tuple(std::forward<decltype(vals)>(vals)...); }
84 };
85} // namespace rpp::utils
Definition functors.hpp:38
Definition functors.hpp:28
Definition functors.hpp:59
Definition functors.hpp:73
Definition functors.hpp:20
Definition functors.hpp:82
Definition functors.hpp:54
Definition functors.hpp:68