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

Detailed Description

Provide a proxy for an argument for use by bsl::format.

Outline

Purpose

Provide a proxy for an argument for use by bsl::format

Classes

Canonical Header

bsl_format.h

Description

This component provides an implementation of the C++20 Standard Library's basic_format_arg , providing access via a "visitor pattern". The value is stored as if using a variant of the following types (as specified by the Standard):

Where basic_format_arg::handle is a type-erased wrapper holding a reference to a user-defined type.

This header is not intended to be included directly. Please include <bsl_format.h> to be able to use bsl::basic_format_arg.

bsl::basic_format_arg differs from the C++20 standard as follows: we provide the C++23 member visit, but we do not provide the overload of visit that accepts an explicitly specified return type.

Usage

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

Example: Default construction and value verification

We do not expect most users of bsl::format to interact with this type directly and instead use bsl::format or bsl::vformat. In addition, there are only a very limited number of public methods so this example is necessarily unrealistic.

Suppose we want to construct a default-constructed basic_format_arg and verify that it contains no value.

assert(!args.get(0));
Definition bslfmt_format_args.h:275
basic_format_arg< t_CONTEXT > get(size_t pos) const BSLS_KEYWORD_NOEXCEPT
Definition bslfmt_format_args.h:404