25template<
typename T,
size_t BUF_SIZE>
28 static_assert(std::is_trivially_constructible_v<T>);
33 if (size <= BUF_SIZE) {
34 sp = std::span<T>(inplaceBuf.data(), size);
36 extBuf = std::make_unique_for_overwrite<T[]>(size);
37 sp = std::span<T>(extBuf.get(), size);
47 template<
typename Range>
51 std::copy(std::begin(range), std::end(range),
begin());
54 [[nodiscard]]
explicit(
false)
operator std::span<T>()
noexcept {
return sp; }
56 [[nodiscard]]
auto size() const noexcept {
return sp.size(); }
57 [[nodiscard]]
auto empty() const noexcept {
return sp.empty(); }
58 [[nodiscard]]
auto data() noexcept {
return sp.data(); }
59 [[nodiscard]]
auto begin() noexcept {
return sp.begin(); }
60 [[nodiscard]]
auto end() noexcept {
return sp.end(); }
62 [[nodiscard]] T& operator[](
size_t index) {
63 assert(index <
size());
77 std::array<T, BUF_SIZE> inplaceBuf;
78 std::unique_ptr<T[]> extBuf;
small_buffer(uninitialized_tag, size_t size)
small_buffer(size_t size, const T &t)
small_buffer(const Range &range)
constexpr void fill(ForwardRange &&range, const T &value)
size_t size(std::string_view utf8)
constexpr auto begin(const zstring_view &x)
constexpr auto end(const zstring_view &x)