fiber
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <type_traits>
4#include <optional>
5
6namespace fiber
7{
8
9 template<class T>
10 concept CStringView = requires(T t) {
11 t.data();
12 t.size();
13 };
14
15// --------------------------------------------------------------------------------
16// CRatio
17// --------------------------------------------------------------------------------
18
19 template<typename T>
20 concept CRatio = requires {
21 { T::num } -> std::convertible_to<intmax_t>;
22 { T::den } -> std::convertible_to<intmax_t>;
23 };
24
25// --------------------------------------------------------------------------------
26// CStdDuration
27// --------------------------------------------------------------------------------
28
29 template<typename T>
30 concept CStdDuration = requires {
31 typename T::rep;
32 typename T::period;
33 requires std::same_as<T, std::chrono::duration<typename T::rep, typename T::period>>;
34 };
35
36// --------------------------------------------------------------------------------
37// CStdOptional
38// --------------------------------------------------------------------------------
39
40
41 template<typename T>
42 struct is_std_optional : std::false_type {};
43
44 // Specialization for std::ratio<num, den>
45 template<class T>
46 struct is_std_optional<std::optional<T>> : std::true_type {};
47
48 template<class T>
50
51 template<typename T>
53
54// --------------------------------------------------------------------------------
55// AwaitableLike
56// --------------------------------------------------------------------------------
57
58 template<typename T>
59 concept AwaitableLike = requires(T t) {
60 { t.await_ready() } -> std::same_as<bool>; // await_ready must return bool
61 { t.await_resume() }; // await_resume can return anything
62 };
63
64} // namespace fiber
65
66
Definition concepts.hpp:59
Definition concepts.hpp:20
Definition concepts.hpp:30
Definition concepts.hpp:52
Definition concepts.hpp:10
Definition Duration.hpp:17
constexpr bool is_std_optional_v
Definition concepts.hpp:49
STL namespace.
Definition concepts.hpp:42