File tree Expand file tree Collapse file tree
include/cpp_event_framework Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -21,46 +21,21 @@ namespace cpp_event_framework
2121 */
2222template <typename T>
2323concept Mutex = std::is_constructible_v<T> && std::is_destructible_v<T> && requires (T a) {
24- {
25- a.lock ()
26- };
27- {
28- a.unlock ()
29- };
24+ { a.lock () };
25+ { a.unlock () };
3026};
3127
3228template <typename T>
3329concept Semaphore = std::is_constructible_v<T, std::ptrdiff_t > && std::is_destructible_v<T> && requires (T a) {
34- {
35- a.acquire ()
36- };
37- {
38- a.release ()
39- };
30+ { a.acquire () };
31+ { a.release () };
4032};
4133
4234/* *
4335 * @brief Concept for a provider of a polymorphic allocator (std::pmr::memory_resource)
4436 */
4537template <typename T>
4638concept PolymorphicAllocatorProvider = requires (T a) {
47- {
48- a.GetAllocator ()
49- } -> std::convertible_to<std::pmr::memory_resource*>;
50- };
51-
52- /* *
53- * @brief Use this allocator to allocate from heap
54- */
55- class HeapAllocator
56- {
57- public:
58- /* *
59- * @brief Default heap-based allocator
60- */
61- static std::pmr::memory_resource* GetAllocator ()
62- {
63- return std::pmr::new_delete_resource ();
64- }
39+ { a.GetAllocator () } -> std::convertible_to<std::pmr::memory_resource*>;
6540};
6641} // namespace cpp_event_framework
Original file line number Diff line number Diff line change 1+ /* *
2+ * @file HeapAllocator.hxx
3+ * @author your name (you@domain.com)
4+ * @brief
5+ * @version 0.1
6+ * @date 2024-08-24
7+ *
8+ * @copyright Copyright (c) 2024
9+ *
10+ */
11+
12+ #pragma once
13+
14+ #include < memory_resource>
15+
16+ namespace cpp_event_framework
17+ {
18+ /* *
19+ * @brief Use this allocator to allocate from heap
20+ */
21+ class HeapAllocator
22+ {
23+ public:
24+ /* *
25+ * @brief Default heap-based allocator
26+ */
27+ static std::pmr::memory_resource* GetAllocator ()
28+ {
29+ return std::pmr::new_delete_resource ();
30+ }
31+ };
32+ } // namespace cpp_event_framework
Original file line number Diff line number Diff line change 1818
1919#include < cpp_event_framework/Concepts.hxx>
2020#include < cpp_event_framework/DemangledTypeName.hxx>
21+ #include < cpp_event_framework/HeapAllocator.hxx>
22+
2123
2224namespace cpp_event_framework
2325{
Original file line number Diff line number Diff line change 1616#include < span>
1717
1818#include < cpp_event_framework/Concepts.hxx>
19+ #include < cpp_event_framework/HeapAllocator.hxx>
1920
2021namespace cpp_event_framework
2122{
You can’t perform that action at this time.
0 commit comments