libcopp  2.2.0
stack_allocator_memory.h
Go to the documentation of this file.
1 // Copyright 2023 owent
2 
3 #pragma once
4 
5 #include <libcopp/utils/config/libcopp_build_features.h>
6 
8 
9 #include <cstddef>
10 
11 #ifdef COPP_HAS_ABI_HEADERS
12 # include COPP_ABI_PREFIX
13 #endif
14 
15 LIBCOPP_COPP_NAMESPACE_BEGIN
16 struct stack_context;
17 
18 namespace allocator {
19 
24 class LIBCOPP_COPP_API stack_allocator_memory {
25  private:
26  void *start_ptr_;
27  std::size_t memory_size_;
28  bool is_used_;
29 
30  public:
31  stack_allocator_memory() LIBCOPP_MACRO_NOEXCEPT;
37  stack_allocator_memory(void *start_ptr, std::size_t max_size) LIBCOPP_MACRO_NOEXCEPT;
38  stack_allocator_memory(stack_allocator_memory &other) LIBCOPP_MACRO_NOEXCEPT;
39  stack_allocator_memory(stack_allocator_memory &&other) LIBCOPP_MACRO_NOEXCEPT;
41 
42  stack_allocator_memory &operator=(stack_allocator_memory &other) LIBCOPP_MACRO_NOEXCEPT;
43  stack_allocator_memory &operator=(stack_allocator_memory &&other) LIBCOPP_MACRO_NOEXCEPT;
44  void swap(stack_allocator_memory &other);
45 
52  void attach(void *start_ptr, std::size_t max_size) LIBCOPP_MACRO_NOEXCEPT;
53 
60  void allocate(stack_context &ctx, std::size_t size) LIBCOPP_MACRO_NOEXCEPT;
61 
66  void deallocate(stack_context &ctx) LIBCOPP_MACRO_NOEXCEPT;
67 };
68 } // namespace allocator
69 LIBCOPP_COPP_NAMESPACE_END
70 
71 #ifdef COPP_HAS_ABI_HEADERS
72 # include COPP_ABI_SUFFIX
73 #endif
memory allocator this allocator will return address of specified memory section
constexpr auto size(TCONTAINER &&container) -> decltype(container.size())
Definition: span.h:44
void swap(intrusive_ptr< T > &lhs, intrusive_ptr< T > &rhs)