Zserio C++ runtime library  1.3.0
Built for Zserio 2.18.0
NewDeleteResource.h
Go to the documentation of this file.
1 #ifndef ZSERIO_PMR_NEW_DELETE_RESOURCE_H_INC
2 #define ZSERIO_PMR_NEW_DELETE_RESOURCE_H_INC
3 
4 #include <new>
5 
6 #include "zserio/Types.h"
8 
9 namespace zserio
10 {
11 namespace pmr
12 {
13 namespace detail
14 {
15 
19 class NewDeleteResource : public MemoryResource
20 {
21 private:
22  void* doAllocate(size_t bytes, size_t) override
23  {
24  return ::operator new(bytes);
25  }
26 
27  void doDeallocate(void* storage, size_t, size_t) override
28  {
29  ::operator delete(storage);
30  }
31 
32  bool doIsEqual(const MemoryResource& other) const noexcept override
33  {
34  return this == &other;
35  }
36 };
37 
38 } // namespace detail
39 
43 MemoryResource* getNewDeleteResource() noexcept;
44 
45 } // namespace pmr
46 } // namespace zserio
47 
48 #endif // ZSERIO_PMR_NEW_DELETE_RESOURCE_H_INC
MemoryResource * getNewDeleteResource() noexcept