30 #ifndef CONST_BUFFER_HPP
31 #define CONST_BUFFER_HPP
57 constexpr
ConstBuffer(std::nullptr_t):data(nullptr), size(0) {}
60 :data(_data), size(_size) {}
75 return data ==
nullptr;
104 :data(_data), size(_size) {}
120 static_assert(
sizeof(T) > 0,
"Empty base type");
122 assert(other.
size %
sizeof(T) == 0);
125 other.
size /
sizeof(T));
129 static_assert(
sizeof(T) > 0,
"Empty base type");
134 return data ==
nullptr;
144 for (
const auto &i : *
this)
155 constexpr iterator
end()
const {
159 constexpr const_iterator
cbegin()
const {
163 constexpr const_iterator
cend()
const {
203 return data[size - 1];
236 reference_type result =
front();
256 assert(
IsNull() == (new_data ==
nullptr));
257 assert(new_data <=
end());
260 size =
end() - new_data;
constexpr ConstBuffer(std::nullptr_t)
void MoveFront(pointer_type new_data)
Move the front pointer to the given address, and adjust the size attribute to retain the old end addr...
reference_type back() const
Returns a reference to the last element.
pointer_type const_iterator
gcc_pure bool Contains(U &&u) const noexcept
void pop_back()
Remove the last element (by moving the tail pointer, does not actually modify the buffer)...
pointer_type const_iterator
static ConstBuffer< T > FromVoid(ConstBuffer< void > other)
Cast a ConstBuffer to a ConstBuffer.
reference_type operator[](size_type i) const
static constexpr ConstBuffer Null()
constexpr iterator end() const
constexpr ConstBuffer< void > ToVoid() const
constexpr ConstBuffer(pointer_type _data, size_type _size)
const void * pointer_type
constexpr ConstBuffer(pointer_type _data, size_type _size)
reference_type front() const
Returns a reference to the first element.
constexpr const_iterator cend() const
constexpr ConstBuffer(std::nullptr_t)
constexpr const_iterator cbegin() const
constexpr bool IsEmpty() const
static constexpr ConstBuffer< void > FromVoid(ConstBuffer< void > other)
void pop_front()
Remove the first element (by moving the head pointer, does not actually modify the buffer)...
constexpr bool IsEmpty() const
reference_type shift()
Remove the first element and return a reference to it.
constexpr bool IsNull() const
constexpr bool IsNull() const
reference_type const_reference_type
A reference to a memory area that is read-only.
constexpr iterator begin() const
constexpr ConstBuffer< void > ToVoid() const
static constexpr ConstBuffer Null()
pointer_type const_pointer_type
void skip_front(size_type n)
pointer_type const_pointer_type