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

copy.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_MEMORY_COPY_HPP
10 #define EAGINE_MEMORY_COPY_HPP
11 
12 #include "../assert.hpp"
13 #include "block.hpp"
14 #include "buffer.hpp"
15 #include <cstring>
16 
17 namespace eagine::memory {
18 
23 static inline auto copy(const_block source, block dest) -> block {
24  EAGINE_ASSERT(dest.size() >= source.size());
25  std::memcpy(dest.data(), source.data(), std_size(source.size()));
26  return block(dest.data(), source.size());
27 }
28 
33 static inline auto copy_into(const_block source, buffer& dest) -> block {
34  dest.resize(source.size());
35  return copy(source, cover(dest));
36 }
37 
38 } // namespace eagine::memory
39 
40 #endif // EAGINE_MEMORY_COPY_HPP
static auto copy_into(const_block source, buffer &dest) -> block
Copies the content of source block to destination buffer.
Definition: copy.hpp:33
static constexpr auto cover(T *addr, S size) noexcept -> span_if_mutable< T >
Creates a span starting at the specified pointer and specified length.
Definition: span.hpp:465
basic_block< false > block
Alias for non-const byte memory span.
Definition: block.hpp:27
Reallocatable owning byte buffer.
Definition: buffer.hpp:22
static constexpr auto std_size(T v) noexcept
Converts argument to std size type.
Definition: types.hpp:52
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
static auto copy(const_block source, block dest) -> block
Copies the content of source block to destination block.
Definition: copy.hpp:23

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