BDE 4.39.x Production Release
Loading...
Searching...
No Matches
bslfmt_formatterstring

Detailed Description

Provide a string formatter for use by bsl::format.

Outline

Purpose

Provide a string formatter for use by bsl::format

Classes

Canonical Header

bsl_format.h

Description

This component provides partial specializations for the bsl::formatter type covering the case for string formatting. Those types meet the requirements as specified in [formatter.requirements] and support all functionality supported by the C++20 std::formatter string type specializations with the following exceptions:

This header is not intended to be included directly. Please include <bsl_format.h> to be able to use specializations of the bsl::formatter for strings.

Usage

In this section we show the intended use of this component.

Example: Formatting a basic string

We do not expect most users of bsl::format to interact with this type directly and instead use bsl::format or bsl::vformat, so this example is necessarily unrealistic.

Suppose we want to test this formatter's ability to a substring with padding and minimum width.

mpc.advance_to(f.parse(mpc));
const char *value = "abcdefghij";
mfc.advance_to(bsl::as_const(f).format(value, mfc));
assert("abc**" == mfc.finalString());
Definition bslfmt_mockformatcontext.h:206
Definition bslfmt_mockparsecontext.h:291
BSLS_KEYWORD_CONSTEXPR bsl::add_const< TYPE >::type & as_const(TYPE &t) BSLS_KEYWORD_NOEXCEPT
Return a reference offering non-modifiable access to the specified t.
Definition bslstl_utility.h:129
Definition bslfmt_formatterbase.h:426