libcopp  1.2.0
stack_allocator_memory.h
Go to the documentation of this file.
1 #ifndef COPP_STACKCONTEXT_ALLOCATOR_MEMORY_H
2 #define COPP_STACKCONTEXT_ALLOCATOR_MEMORY_H
3 
4 #pragma once
5 
6 #include <cstddef>
7 
9 
10 #ifdef COPP_HAS_ABI_HEADERS
11 #include COPP_ABI_PREFIX
12 #endif
13 
14 namespace copp {
15  struct stack_context;
16 
17  namespace allocator {
18 
24  private:
25  void * start_ptr_;
26  std::size_t memory_size_;
27  bool is_used_;
28 
29  public:
30  stack_allocator_memory() UTIL_CONFIG_NOEXCEPT;
36  stack_allocator_memory(void *start_ptr, std::size_t max_size) UTIL_CONFIG_NOEXCEPT;
37  stack_allocator_memory(stack_allocator_memory &other) UTIL_CONFIG_NOEXCEPT;
38 #if defined(UTIL_CONFIG_COMPILER_CXX_RVALUE_REFERENCES) && UTIL_CONFIG_COMPILER_CXX_RVALUE_REFERENCES
39  stack_allocator_memory(stack_allocator_memory &&other) UTIL_CONFIG_NOEXCEPT;
40 #endif
42 
43  stack_allocator_memory &operator=(stack_allocator_memory &other) UTIL_CONFIG_NOEXCEPT;
44 #if defined(UTIL_CONFIG_COMPILER_CXX_RVALUE_REFERENCES) && UTIL_CONFIG_COMPILER_CXX_RVALUE_REFERENCES
45  stack_allocator_memory &operator=(stack_allocator_memory &&other) UTIL_CONFIG_NOEXCEPT;
46 #endif
47  void swap(stack_allocator_memory &other);
48 
55  void attach(void *start_ptr, std::size_t max_size) UTIL_CONFIG_NOEXCEPT;
56 
63  void allocate(stack_context &ctx, std::size_t size) UTIL_CONFIG_NOEXCEPT;
64 
69  void deallocate(stack_context &ctx) UTIL_CONFIG_NOEXCEPT;
70  };
71  } // namespace allocator
72 } // namespace copp
73 
74 #ifdef COPP_HAS_ABI_HEADERS
75 #include COPP_ABI_SUFFIX
76 #endif
77 
78 #endif
memory allocator this allocator will return address of specified memory section
void allocate(stack_context &ctx, std::size_t size) UTIL_CONFIG_NOEXCEPT
STL namespace.
void deallocate(stack_context &ctx) UTIL_CONFIG_NOEXCEPT
void swap(stack_allocator_memory &other)
void attach(void *start_ptr, std::size_t max_size) UTIL_CONFIG_NOEXCEPT
stack_allocator_memory & operator=(stack_allocator_memory &other) UTIL_CONFIG_NOEXCEPT