Go to the documentation of this file.
9 #ifndef EAGINE_STRUCT_MEMORY_BLOCK_HPP
10 #define EAGINE_STRUCT_MEMORY_BLOCK_HPP
14 #include <type_traits>
19 class structured_memory_block {
21 memory::basic_block<std::is_const_v<T>> _blk;
23 template <
typename X = T,
typename = std::enable_if_t<!std::is_const_v<X>>>
24 auto _ptr() noexcept {
25 EAGINE_ASSERT(is_valid_block(_blk));
26 return static_cast<X*
>(_blk.addr());
29 auto _cptr() const noexcept {
30 EAGINE_ASSERT(is_valid_block(_blk));
31 return static_cast<const T*
>(_blk.addr());
36 return !blk.empty() && (blk.is_aligned_as<T>()) &&
42 EAGINE_ASSERT(is_valid_block(_blk));
47 typename = std::enable_if_t<!std::is_const_v<X> && std::is_same_v<X, T>>>
48 auto get() noexcept -> X& {
54 typename = std::enable_if_t<!std::is_const_v<X> && std::is_same_v<X, T>>>
55 auto operator->() noexcept -> X* {
59 auto get() const noexcept -> const T& {
63 auto operator->() const noexcept -> const T* {
70 #endif // EAGINE_STRUCT_MEMORY_BLOCK_HPP
Common code is placed in this namespace.
Definition: eagine.hpp:21
static constexpr auto can_accomodate(basic_span< B, P, S > blk, span_size_t count, type_identity< T > tid={}) noexcept
Indicates if the specified memory block can accomodate count elements of T.
Definition: span.hpp:539
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
basic_span< std::conditional_t< IsConst, const byte, byte > > basic_block
Alias for byte spans.
Definition: block.hpp:22