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

aligned_block.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_MEMORY_ALIGNED_BLOCK_HPP
10 #define EAGINE_MEMORY_ALIGNED_BLOCK_HPP
11 
12 #include "block.hpp"
13 #include <type_traits>
14 
15 namespace eagine::memory {
16 //------------------------------------------------------------------------------
21 template <std::size_t Size>
23 public:
25  auto get() noexcept -> block {
26  return as_bytes(cover_one(_storage));
27  }
28 
30  auto get() const noexcept -> const_block {
31  return as_bytes(view_one(_storage));
32  }
33 
36  operator block() noexcept {
37  return get();
38  }
39 
42  operator const_block() const noexcept {
43  return get();
44  }
45 
46 private:
47  std::aligned_storage_t<Size> _storage{};
48 };
49 //------------------------------------------------------------------------------
50 } // namespace eagine::memory
51 
52 #endif // EAGINE_MEMORY_ALIGNED_BLOCK_HPP
auto get() const noexcept -> const_block
Returns a view of the internal storage as a const block.
Definition: aligned_block.hpp:30
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
basic_block< true > const_block
Alias for const byte memory span.
Definition: block.hpp:32
basic_block< false > block
Alias for non-const byte memory span.
Definition: block.hpp:27
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
auto get() noexcept -> block
Returns a view of the internal storage as a block.
Definition: aligned_block.hpp:25
Class containing store of the specified size convertible to block.
Definition: aligned_block.hpp:22

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