OGLplus  (0.59.0) a C++ wrapper for rendering APIs

null_alloc.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_MEMORY_NULL_ALLOC_HPP
10 #define EAGINE_MEMORY_NULL_ALLOC_HPP
11 
12 #include "../assert.hpp"
13 #include "byte_alloc.hpp"
14 
15 namespace eagine::memory {
16 
17 template <typename Policy = default_byte_allocator_policy>
18 class null_byte_allocator
19  : public byte_allocator_impl<Policy, null_byte_allocator> {
20 public:
21  using size_type = span_size_t;
22 
23  auto equal(byte_allocator* a) const noexcept -> bool override {
24  return dynamic_cast<null_byte_allocator*>(a) != nullptr;
25  }
26 
27  auto max_size(size_type) noexcept -> size_type override {
28  return 0;
29  }
30 
31  auto has_allocated(const owned_block&, size_type) noexcept
32  -> tribool override {
33  return indeterminate;
34  }
35 
36  auto allocate(size_type, size_type) noexcept -> owned_block override {
37  return {};
38  }
39 
40  void deallocate(owned_block&& b, size_type) noexcept override {
41  EAGINE_ASSERT(b.empty());
42  }
43 };
44 
45 } // namespace eagine::memory
46 
47 #endif // EAGINE_MEMORY_NULL_ALLOC_HPP
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
constexpr static const indeterminate_t indeterminate
Constant representing unspecified tribool value.
Definition: tribool.hpp:24

Copyright © 2015-2021 Matúš Chochlík.
<chochlik -at -gmail.com>
Documentation generated on Tue Apr 13 2021 by Doxygen (version 1.8.17).