mp_units::utility::write_padded

Writes a string to an output iterator with fill/align/width padding.

Synopsis

Declared in <mp-units/utility/format.h>

template<
    typename Char,
    std::output_iterator<Char> Out>
constexpr
Out
write_padded(
    Out out,
    std::basic_string_view<Char> s,
    int width,
    fmt_align align,
    fill_t<Char> const& fill);

Description

Avoids instantiating format_to/vformat_to infrastructure for the common padding use-case inside formatter<Unit>, formatter<Dimension>, and formatter<quantity> specializations.

Return Value

the output iterator after writing the padded string

Parameters

NameDescription
outthe output iterator to write to
sthe string to write
widththe minimum field width; s is padded with fill to reach it
alignhow s is aligned within the padded field
fillthe character(s) used to pad s up to width