Condy v1.8
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
type_traits.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <stop_token>
8#include <type_traits>
9#include <utility>
10
11namespace condy {
12namespace detail {
13
14template <typename T, typename Callback>
15concept HasStopCallback =
16 requires { typename T::template callback_type<Callback>; };
17
18template <typename T, typename Callback> struct stop_callback_traits;
19template <typename T, typename Callback>
20 requires HasStopCallback<T, Callback>
21struct stop_callback_traits<T, Callback> {
22 using type = typename T::template callback_type<Callback>;
23};
24template <typename T, typename Callback>
25 requires(!HasStopCallback<T, Callback> &&
26 std::is_same_v<T, std::stop_token>)
27struct stop_callback_traits<T, Callback> {
28 using type = std::stop_callback<Callback>;
29};
30
31template <typename T, typename Callback>
32using stop_callback_t = typename stop_callback_traits<T, Callback>::type;
33
34template <typename Sender, typename Receiver>
35using operation_state_t = decltype(std::declval<Sender &&>().connect_impl(
36 std::declval<Receiver &&>()));
37
38template <typename Receiver>
39using stop_token_t =
40 std::remove_cvref_t<decltype(std::declval<Receiver &>().get_stop_token())>;
41
42} // namespace detail
43} // namespace condy
The main namespace for the Condy library.
Definition condy.hpp:37