<xstd/ints/format/div_result.hpp>¶
std::formatter<xstd::div_result<I>, charT>¶
template<xstd::integer I, class charT>
struct formatter<xstd::div_result<I>, charT> : see below {
template<class FormatContext>
constexpr auto format(const xstd::div_result<I>& d, FormatContext& ctx) const -> typename FormatContext::iterator;
};
Formats a div_result as its quotient and remainder, each in decimal.
Its base, which supplies parse and with it the grammar of the format specification, is the first of these that
applies: formatter<tuple<const I&, const I&>, charT> where that tuple is formattable; formatter<tuple<D, D>, charT>
where the library formats tuples, for an exposition-only D holding the digits xstd::to_chars writes, which its own
formatter copies out unchanged; and formatter<basic_string_view<charT>, charT> otherwise.
Member functions¶
parse:- Effects: Where the library formats tuples, accepts the tuple specification of
[format.tuple], fill and align, width, and
norm, whateverIis. - Effects: On a library that formats no tuple, accepts a string's specification.
- Throws:
format_errorfor any other specification, which a format string checked at compile time makes an ill-formed call.
- Effects: Where the library formats tuples, accepts the tuple specification of
[format.tuple], fill and align, width, and
format:- Effects: Writes
(, the quotient,,, the remainder and), each member in decimal asxstd::to_charswrites it;nleaves out the brackets, andmleaves them out and writes:as the separator. The fill, alignment and width then apply to the whole. - Remarks: It is
constexprwhere__cpp_lib_constexpr_formatis at least202511L, as P3391R2 makes the base's, and not otherwise.
- Effects: Writes
Notes¶
- The text is the same whichever base applies, and over every signed exact-width type, standard, 128-bit and bit-precise.
- The text is the same for a wide format string.
- The text is the same over an unsigned element type,
std::uint8_tincluded, whose members are written as numbers rather than as characters.
See also¶
| Entity | Relation |
|---|---|
div_result |
the class this formats |
to_chars |
writes each member |
std::formatter |
the standard's formatter, which this specializes |