48 template <
class... Args>
49 constexpr holder(Args&&... args) noexcept
50 :
value(std::forward<Args>(args)...)
63 return std::move(
value);
71 [[nodiscard]]
constexpr const T&
storage() const noexcept
81 [[nodiscard]]
constexpr T&
storage() noexcept
93 value = std::move(other);
159 template <std::ranges::input_range R>
161 !std::same_as<u8_buffer<T>, std::decay_t<R>>
162 && std::convertible_to<std::ranges::range_value_t<R>, T>
181 template <allocator A = std::allocator<std::u
int8_t>>
182 constexpr u8_buffer(T* data_ptr, std::size_t count,
const A& a = A());
204 std::fill(this->
begin(), this->
end(), val);
208 template <std::ranges::input_range R>
209 requires(!std::same_as<u8_buffer<T>, std::decay_t<R>>
210 && std::convertible_to<std::ranges::range_value_t<R>, T>)
213 , buffer_adaptor_type(holder_type::value)
223 std::copy(ilist.begin(), ilist.end(), this->begin());
227 template <allocator A>
229 :
holder_type{reinterpret_cast<uint8_t*>(data_ptr), count * sizeof(T), a}
constexpr iterator begin() noexcept
constexpr size_type size() const noexcept(!SPARROW_CONTRACTS_THROW_ON_FAILURE)
constexpr buffer_adaptor(FromBufferRef buf)
constexpr iterator end() noexcept
A holder class that wraps a value and provides storage management.
constexpr void assign(T &&other)
Assigns a new value to the storage.
constexpr T extract_storage() &&noexcept
Extracts the storage by moving the wrapped value.
constexpr T & storage() noexcept
Gets a reference to the storage.
constexpr holder(Args &&... args) noexcept
Constructs a holder with the given arguments forwarded to the wrapped value.
constexpr const T & storage() const noexcept
Gets a constant reference to the storage.
buffer_adaptor< IT, buffer< std::uint8_t > & > buffer_adaptor_type
u8_buffer & operator=(u8_buffer &&other)=delete
Move assignment operator (deleted).
constexpr u8_buffer(std::initializer_list< T > ilist)
Constructs a buffer with the elements of the initializer list ilist.
u8_buffer & operator=(u8_buffer &other)=delete
Copy assignment operator (deleted).
constexpr buffer< std::uint8_t > extract_storage() &&noexcept
Extracts the storage by moving the wrapped value.
detail::holder< buffer< std::uint8_t > > holder_type
constexpr u8_buffer(const u8_buffer &other)
Copy constructor.
constexpr u8_buffer(T *data_ptr, std::size_t count, const A &a=A())
Constructs a buffer by taking ownership of the storage pointed to by data_ptr.
constexpr u8_buffer(R &&range)
Constructs a buffer with the elements of the range range.
~u8_buffer()=default
Destructor.
constexpr u8_buffer(u8_buffer &&other) noexcept
Move constructor.
constexpr u8_buffer(std::size_t n, const T &val=T{})
Constructs a buffer with n elements, each initialized to val.
constexpr std::ranges::copy_result< std::ranges::borrowed_iterator_t< R >, O > copy(R &&r, O result)
constexpr std::size_t range_size(R &&r)