Represents a read-only view of a contiguous block of bytes.
ConstBuf is intended for passing ownership of read-only data, or providing an unowned view, optionally slicing the view between layers. Unlike Buf, ConstBuf does not support Reclaim() or expose its base pointer. Once a ConstBuf is sliced or truncated, the excluded bytes cannot be recovered.
An empty() ConstBuf has no bytes (size() == 0). A null ConstBuf has no bytes, and its data() pointer is nullptr. A ConstBuf is null when default-constructed, moved-from, or reset.
An empty ConstBuf is not necessarily null (for example, if it was created with ConstBuf::ZeroLength() or sliced or truncated to length 0), in which case data() returns a non-null pointer.
Nullness can be checked via comparison to nullptr (buf == nullptr, buf != nullptr). operator bool is not provided to prevent confusion between nullness and emptiness.
|
|
constexpr | ConstBuf ()=default |
| | Constructs a null ConstBuf.
|
| |
|
constexpr | ConstBuf (std::nullptr_t) noexcept |
| | Constructs a null ConstBuf.
|
| |
| template<typename T , typename = std::enable_if_t<std::is_integral_v<T>>> |
| | ConstBuf (T)=delete |
| |
| constexpr | ConstBuf (ConstBuf &&other) noexcept |
| |
| constexpr | ConstBuf (Buf &&other) noexcept |
| |
|
| ConstBuf (const ConstBuf &)=delete |
| |
|
| ~ConstBuf ()=default |
| | Destructor. Releases the owned memory (if any) back to the allocator.
|
| |
| ConstBuf & | operator= (ConstBuf &&other) noexcept=default |
| |
| ConstBuf & | operator= (Buf &&other) noexcept |
| |
|
ConstBuf & | operator= (const ConstBuf &)=delete |
| |
| ConstBuf & | operator= (std::nullptr_t) noexcept |
| |
|
template<typename T , typename = std::enable_if_t<std::is_integral_v<T>>> |
| ConstBuf & | operator= (T)=delete |
| | Integers cannot be assigned to a ConstBuf, not even the literal 0.
|
| |
| | operator bool () const =delete |
| |
|
reference | operator[] (size_t index) const |
| | Accesses the byte at the specified index.
|
| |
| constexpr pointer | data () const |
| |
|
constexpr size_t | size () const |
| | Returns the number of bytes in the buffer view.
|
| |
| constexpr bool | empty () const |
| |
|
iterator | begin () const |
| | Returns a read-only iterator pointing to the beginning of the data.
|
| |
|
iterator | end () const |
| | Returns a read-only iterator pointing past the end of the data.
|
| |
|
const_iterator | cbegin () const |
| | Returns a read-only iterator pointing to the beginning of the data.
|
| |
|
const_iterator | cend () const |
| | Returns a read-only iterator pointing past the end of the data.
|
| |
| constexpr bool | owned () const |
| |
| constexpr Deallocator * | deallocator () const |
| |
|
void | reset () |
| | Frees the owned memory (if any) and sets the buffer to null.
|
| |
|
void | swap (ConstBuf &other) noexcept |
| | Exchanges the contents of this ConstBuf with other.
|
| |
|
|
class | multibuf::v2::internal::GenericMultiBuf |
| |
|
constexpr bool | operator== (const ConstBuf &lhs, std::nullptr_t) noexcept |
| |
|
constexpr bool | operator== (std::nullptr_t, const ConstBuf &rhs) noexcept |
| |
|
constexpr bool | operator!= (const ConstBuf &lhs, std::nullptr_t) noexcept |
| |
|
constexpr bool | operator!= (std::nullptr_t, const ConstBuf &rhs) noexcept |
| |
|
void | swap (ConstBuf &lhs, ConstBuf &rhs) noexcept |
| | Exchanges the contents of two ConstBufs.
|
| |
| ConstBuf | Slice (ConstBuf &&const_buf, size_t offset, size_t length) |
| |