Go to the documentation of this file.
9 #ifndef EAGINE_MEMORY_BLOCK_HPP
10 #define EAGINE_MEMORY_BLOCK_HPP
12 #include "../assert.hpp"
17 namespace eagine::memory {
21 template <
bool IsConst>
38 template <
typename T,
typename P,
typename S>
49 return accomodate<char>(blk);
57 return accomodate<const char>(blk);
80 if(
this != std::addressof(temp)) {
81 static_cast<block&
>(*this) =
static_cast<const block&
>(temp);
96 EAGINE_ASSERT(
empty());
124 #endif // EAGINE_MEMORY_BLOCK_HPP
constexpr auto empty() const noexcept -> bool
Indicates that the span is empty.
Definition: span.hpp:235
static constexpr auto as_bytes(basic_span< T, P, S > spn) noexcept -> basic_block< std::is_const_v< T >>
Converts a span into a basic_block.
Definition: block.hpp:39
auto operator=(owned_block &&temp) noexcept -> owned_block &
Move assignment operator.
Definition: block.hpp:79
constexpr owned_block() noexcept=default
Default constructor.
Specialization of block indicating byte span ownership.
Definition: block.hpp:66
basic_block< false > block
Alias for non-const byte memory span.
Definition: block.hpp:27
Base class for classes that act as memory block owners.
Definition: block.hpp:109
auto reset() noexcept -> auto &
Resets this span.
Definition: span.hpp:200
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
static void release_block(owned_block &&b) noexcept
Should be called to release the ownership of a memory block.
Definition: block.hpp:117
constexpr auto begin_addr() const noexcept -> address_type
Returns the memory address of the start of the span.
Definition: span.hpp:284
~owned_block() noexcept
Destructor.
Definition: block.hpp:95
static constexpr auto as_chars(const_block blk) noexcept
Converts a block into a span of characters.
Definition: block.hpp:56
static auto acquire_block(block b) noexcept -> owned_block
Should be called to take the ownership of a memory block.
Definition: block.hpp:112
owned_block(owned_block &&temp) noexcept
Move constructor.
Definition: block.hpp:73