template<class Container>
binary_io::basic_memory_ostream class final

A stream which composes a dynamically sized container.

Template parameters
Container The container type to use as the underlying buffer.

Base classes

template<class Container>
class basic_memory_stream_base<Container>
Implements the common interface of every memory_stream.
template<class Derived>
class ostream_interface<basic_memory_ostream<Container>>
A CRTP utility which can be used to flesh out the interface of a given stream.

Public types

using container_type = typename super::container_type

Buffer management

auto rdbuf() -> container_type& noexcept
Provides mutable access to the underlying buffer.
auto rdbuf() const -> const container_type& noexcept
Provides immutable access to the underlying buffer.

Formatting

auto endian() const -> std::endian noexcept
Gets the current default endian format.
void endian(std::endian a_endian) noexcept
Sets the default endian format.

Position

void seek_absolute(binary_io::streamoff a_pos) noexcept
Seek to an absolute position in the stream (i.e. from the beginning).
void seek_relative(binary_io::streamoff a_off) noexcept
Seek to a position in the stream relative to the current position.
auto tell() const -> binary_io::streamoff noexcept
Gets the current stream position.

Writing

void write(Args... a_args)
Writes the given values into the output stream.
void write(std::endian a_endian, Args... a_args)
Writes the given values into the output stream, with the given endian format.
void write_bytes(std::span<const std::byte> a_src)
Writes bytes into the given buffer.

Function documentation

template<class Container>
void binary_io::basic_memory_ostream<Container>::write_bytes(std::span<const std::byte> a_src)

Writes bytes into the given buffer.

Parameters
a_src The buffer to write bytes from.
Exceptions
binary_io::buffer_exhausted Thrown when the buffer has less than the requested number of bytes.