YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
type_traits_impl.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <yaclib/fwd.hpp>
4
5#include <iterator>
6#include <type_traits>
7
8namespace yaclib::detail {
9
10template <typename...>
11struct Head;
12
13template <typename T, typename... Args>
14struct Head<T, Args...> final {
15 using Type = T;
16};
17
18template <typename Func, typename... Args>
20 static constexpr bool Value = std::is_invocable_v<Func, Args...>;
21};
22
23template <typename Func>
25 static constexpr bool Value = std::is_invocable_v<Func>;
26};
27
28template <typename Func, typename... Args>
29struct Invoke final {
30 using Type = std::invoke_result_t<Func, Args...>;
31};
32
33template <typename Func>
35 using Type = std::invoke_result_t<Func>;
36};
37
38template <template <typename...> typename Instance, typename...>
39struct IsInstantiationOf final {
40 static constexpr bool Value = false;
41};
42
43template <template <typename...> typename Instance, typename... Args>
45 static constexpr bool Value = true;
46};
47
48template <template <typename...> typename Instance, typename T>
50 using Value = T;
51};
52
53template <template <typename...> typename Instance, typename V>
55 using Value = V;
56};
57
58template <template <typename...> typename Instance, typename T>
60 using Value = T;
61 using Trait = T;
62};
63
64template <template <typename...> typename Instance, typename V, typename T>
66 using Value = V;
67 using Trait = T;
68};
69
70template <typename T>
72 using Value = T;
73 using Trait = T;
74};
75
76template <typename V, typename T>
78 using Value = V;
79 using Trait = T;
80};
81
82template <typename V, typename T>
83struct AsyncTypes<Future<V, T>> final {
84 using Value = V;
85 using Trait = T;
86};
87
88template <typename V, typename T>
89struct AsyncTypes<FutureOn<V, T>> final {
90 using Value = V;
91 using Trait = T;
92};
93
94template <typename V, typename T>
96 using Value = V;
97 using Trait = T;
98};
99
100template <typename V, typename T>
102 using Value = V;
103 using Trait = T;
104};
105
106template <typename V, typename T>
108 using Value = V;
109 using Trait = T;
110};
111
112template <typename It, typename Tag, typename = std::void_t<>>
114 static constexpr bool Value = false;
115};
116
117template <typename It, typename Tag>
118struct HasIteratorCategory<It, Tag, std::void_t<typename std::iterator_traits<It>::iterator_category>> final {
119 static constexpr bool Value = std::is_base_of_v<Tag, typename std::iterator_traits<It>::iterator_category>;
120};
121
122template <typename It, typename = std::void_t<>>
124 static constexpr bool Value = false;
125};
126
127template <typename It>
128struct IsInputIterator<It, std::void_t<decltype(*std::declval<const It&>()), decltype(++std::declval<It&>())>> final {
130};
131
132template <typename Sentinel, typename It, typename = std::void_t<>>
134 static constexpr bool Value = false;
135};
136
137template <typename Sentinel, typename It>
139 std::void_t<decltype(std::declval<const It&>() == std::declval<const Sentinel&>())>> {
140 static constexpr bool Value = true;
141};
142
143template <typename It, typename Sentinel>
147
148template <typename Range>
149using RangeIterator = std::decay_t<decltype(std::begin(std::declval<Range&>()))>;
150
151template <typename Range>
152using RangeSentinel = std::decay_t<decltype(std::end(std::declval<Range&>()))>;
153
154template <typename Range, typename = std::void_t<>>
156 static constexpr bool Value = false;
157};
158
159template <typename Range>
160struct IsInputRange<Range, std::void_t<RangeIterator<Range>, RangeSentinel<Range>>> {
162};
163
164template <typename It, typename Sentinel, typename = std::void_t<>>
166 static constexpr bool Value = false;
167};
168
169template <typename It, typename Sentinel>
171 std::void_t<decltype(std::declval<const Sentinel&>() - std::declval<const It&>()),
172 decltype(std::declval<const It&>() - std::declval<const Sentinel&>())>> {
173 static constexpr bool Value = true;
174};
175
176} // namespace yaclib::detail
Provides a mechanism to access the result of async operations.
Definition future.hpp:21
Provides a mechanism to access the result of async operations.
Definition future.hpp:248
Provides a mechanism to access the result of async operations.
Definition future.hpp:214
constexpr char Tag() noexcept
Definition core.hpp:312
std::decay_t< decltype(std::begin(std::declval< Range & >()))> RangeIterator
std::decay_t< decltype(std::end(std::declval< Range & >()))> RangeSentinel
Contract< V, T > MakeContract()
Creates related future and promise.
Definition contract.hpp:25
std::invoke_result_t< Func > Type
std::invoke_result_t< Func, Args... > Type
static constexpr bool Value