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

split_span.hpp
Go to the documentation of this file.
1 
9 #ifndef EAGINE_MEMORY_SPLIT_SPAN_HPP
10 #define EAGINE_MEMORY_SPLIT_SPAN_HPP
11 
12 #include "span_algo.hpp"
13 
14 namespace eagine::memory {
15 //------------------------------------------------------------------------------
22 template <
23  typename ValueType,
24  typename Pointer = ValueType*,
25  typename SizeType = span_size_t>
27 public:
29  constexpr basic_split_span() noexcept = default;
30 
32  constexpr basic_split_span(
34  : _span{spn} {}
35 
40  constexpr auto split_position() const noexcept -> span_size_t {
41  return _split;
42  }
43 
47  constexpr auto head() const noexcept {
48  return head(_span, _split);
49  }
50 
54  constexpr auto tail() const noexcept {
55  return skip(_span, _split);
56  }
57 
61  auto advance(span_size_t amount) noexcept -> auto& {
62  _split += amount;
63  return *this;
64  }
65 
69  auto skip_to_end() noexcept -> auto& {
70  _split = _span.size();
71  return *this;
72  }
73 
74 private:
76  span_size_t _split{0};
77 };
78 //------------------------------------------------------------------------------
79 } // namespace eagine::memory
80 
81 #endif // EAGINE_MEMORY_SPLIT_SPAN_HPP
std::ptrdiff_t span_size_t
Signed span size type used by eagine.
Definition: types.hpp:36
constexpr auto head() const noexcept
Returns the part of the block before the split (split not included).
Definition: split_span.hpp:47
auto skip_to_end() noexcept -> auto &
Moves the split to the end of the block.
Definition: split_span.hpp:69
constexpr auto tail() const noexcept
Returns the part of the block starting at the split until the end.
Definition: split_span.hpp:54
Non-owning view of a contiguous range of memory with ValueType elements.
Definition: flatten_fwd.hpp:16
static constexpr auto skip(basic_span< T, P, S > s, L l) noexcept -> basic_span< T, P, S >
Skips a specified count of elements from the front of a span.
Definition: span_algo.hpp:60
auto advance(span_size_t amount) noexcept -> auto &
Moves the split by the specified amout (number of bytes).
Definition: split_span.hpp:61
constexpr auto split_position() const noexcept -> span_size_t
Returns the position of split as count of bytes since beginning.
Definition: split_span.hpp:40
Template for classes representing a memory span split in two parts.
Definition: split_span.hpp:26
constexpr basic_split_span(basic_span< ValueType, Pointer, SizeType > spn) noexcept
Initializing constructor.
Definition: split_span.hpp:32
constexpr basic_split_span() noexcept=default
Default constructor.

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