Condy v1.6.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
concepts.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include <concepts>
8#include <cstdint>
9#include <type_traits>
10
11struct io_uring_cqe;
12struct io_uring_sqe;
13
14namespace condy {
15
16class Ring;
17class BufferBase;
18
19namespace detail {
20
21struct FixedFd;
22
23} // namespace detail
24
25template <typename T>
26concept PrepFuncLike = requires(T prep_func, Ring *ring) {
27 { prep_func(ring) } -> std::same_as<io_uring_sqe *>;
28};
29
30template <typename T>
31concept CQEHandlerLike = requires(T handler, io_uring_cqe *cqe) {
32 { handler(cqe) } noexcept;
33};
34
35template <typename T>
36concept BufferRingLike = requires(T br, io_uring_cqe *cqe) {
37 { br.bgid() } -> std::same_as<uint16_t>;
38 { br.handle_finish(cqe) };
39};
40
41template <typename T>
42concept BufferLike = std::derived_from<std::decay_t<T>, BufferBase>;
43
44template <typename T>
45concept FdLike = std::same_as<std::decay_t<T>, int> ||
46 std::same_as<std::decay_t<T>, detail::FixedFd>;
47
48template <typename T, typename... Us>
49concept AnySameAs = (std::same_as<T, Us> || ...);
50
51} // namespace condy
The main namespace for the Condy library.
Definition condy.hpp:30