Vince's CSV Parser
Loading...
Searching...
No Matches
row_deque.hpp
Go to the documentation of this file.
1
5#pragma once
6
7#include "common.hpp"
8
9#if CSV_ENABLE_THREADS
10#include "thread_safe_deque.hpp"
11#else
13#endif
14
15#include <cstddef>
16#include <type_traits>
17#include <utility>
18
19#ifdef CSV_HAS_CXX20
20#include <concepts>
21#endif
22
23namespace csv {
24 namespace internals {
25#if !CSV_ENABLE_THREADS
26 template<typename T>
27 using ThreadSafeDeque = SingleThreadDeque<T>;
28#endif
29
30#ifdef CSV_HAS_CXX20
31 template<typename Q, typename T>
32 concept RowDequeLike = requires(Q q, const Q cq, T item, size_t n) {
33 { Q(100) };
34 { q.push_back(std::move(item)) } -> std::same_as<void>;
35 { q.pop_front() } -> std::same_as<T>;
36 { cq.empty() } -> std::same_as<bool>;
37 { cq.is_waitable() } -> std::same_as<bool>;
38 { q.wait() } -> std::same_as<void>;
39 { q.notify_all() } -> std::same_as<void>;
40 { q.kill_all() } -> std::same_as<void>;
41 { q.front() } -> std::same_as<T&>;
42 { q[n] } -> std::same_as<T&>;
43 { cq.size() } -> std::same_as<size_t>;
44 { q.begin() };
45 { q.end() };
46 };
47
48 #if CSV_ENABLE_THREADS
49 static_assert(RowDequeLike<ThreadSafeDeque<int>, int>, "ThreadSafeDeque must satisfy RowDequeLike contract");
50 #else
51 static_assert(RowDequeLike<SingleThreadDeque<int>, int>, "SingleThreadDeque must satisfy RowDequeLike contract");
52 static_assert(RowDequeLike<ThreadSafeDeque<int>, int>, "Selected ThreadSafeDeque alias must satisfy RowDequeLike contract");
53 #endif
54#endif
55 }
56}
A standalone header file containing shared code.
The all encompassing namespace.
Single-threaded row deque implementation.
Thread-safe deque for producer-consumer patterns.