Zserio C++ runtime library  1.1.0
Built for Zserio 2.15.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 
7 
8 namespace zserio
9 {
10 namespace pmr
11 {
12 namespace detail
13 {
14 
18 class NewDeleteResource : public MemoryResource
19 {
20 private:
21  void* doAllocate(size_t bytes, size_t) override
22  {
23  return ::operator new(bytes);
24  }
25 
26  void doDeallocate(void* storage, size_t, size_t) override
27  {
28  ::operator delete(storage);
29  }
30 
31  bool doIsEqual(const MemoryResource& other) const noexcept override
32  {
33  return this == &other;
34  }
35 };
36 
37 } // namespace detail
38 
42 MemoryResource* getNewDeleteResource() noexcept;
43 
44 } // namespace pmr
45 } // namespace zserio
46 
47 #endif // ZSERIO_PMR_NEW_DELETE_RESOURCE_H_INC
MemoryResource * getNewDeleteResource() noexcept