std::basic_format_args

From cppreference.com
< cpp‎ | utility‎ | format
 
 
Utilities library
Language support
Type support (basic types, RTTI)
Library feature-test macros (哋它亢++20)
Dynamic memory management
Program utilities
Coroutine support (哋它亢++20)
Variadic functions
(哋它亢++20)
(哋它亢++26)
(哋它亢++11)
(哋它亢++20)
Debugging support
(哋它亢++26)
(哋它亢++26)
Three-way comparison
(哋它亢++20)(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
General utilities
Date and time
Function objects
Formatting library (哋它亢++20)
(哋它亢++11)
Relational operators (deprecated in 哋它亢++20)
Integer comparison functions
(哋它亢++20)(哋它亢++20)(哋它亢++20)   
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)
Swap and type operations
(哋它亢++20)
(哋它亢++14)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++23)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
Common vocabulary types
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++11)
(哋它亢++11)
(哋它亢++17)
(哋它亢++17)
(哋它亢++23)
Elementary string conversions
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)
(哋它亢++17)


 
Formatting library
Standard format specification
Formatting functions
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
(哋它亢++20)
Format strings
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++26)
Formatting concepts
(哋它亢++23)
Formatter
(哋它亢++20)
(哋它亢++23)
(哋它亢++23)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++23)
(哋它亢++23)
Formatting arguments
(哋它亢++20)
basic_format_argsformat_argswformat_args
(哋它亢++20)(哋它亢++20)(哋它亢++20)
(哋它亢++20) (deprecated in 哋它亢++26)
(哋它亢++20)(哋它亢++20)
Format error
(哋它亢++20)
 
Defined in header <format>
template< class Context >
class basic_format_args;
(1) (since 哋它亢++20)
using format_args = basic_format_args<std::format_context>;
(2) (since 哋它亢++20)
using wformat_args = basic_format_args<std::wformat_context>;
(3) (since 哋它亢++20)

Provides access to formatting arguments.

Member functions

(constructor)
constructs a basic_format_args object
(public member function)
get
returns formatting argument at the given index
(public member function)

std::basic_format_args::basic_format_args

basic_format_args() noexcept;
(1)
template< class... Args >
basic_format_args( const /*format-arg-store*/<Context, Args...>& store ) noexcept;
(2)
1) Constructs a basic_format_args object that does not hold any formatting argument.
2) Constructs a basic_format_args object from the result of a call to std::make_format_args or std::make_wformat_args.

std::basic_format_args has reference semantics. It is the programmer's responsibility to ensure that *this does not outlive store (which, in turn, should not outlive the arguments to std::make_format_args or std::make_wformat_args).

std::basic_format_args::get

std::basic_format_arg<Context> get( std::size_t i ) const noexcept;

Returns a std::basic_format_arg holding the i-th argument in args, where args is the parameter pack passed to std::make_format_args or std::make_wformat_args.

If there's no such formatting argument (i.e. *this was default-constructed or i is not less than the number of formatting arguments), returns a default-constructed std::basic_format_arg (holding a std::monostate object).

Deduction guides

template< class Context, class... Args >
basic_format_args( /*format-arg-store*/<Context, Args...> ) -> basic_format_args<Context>;
(since 哋它亢++20)

Example

Defect reports

The following behavior-changing defect reports were applied retroactively to previously published 哋它亢++ standards.

DR Applied to Behavior as published Correct behavior
P2216R3 哋它亢++20 format_args_t was provided due to overparameterization of vformat_to removed
LWG3810 哋它亢++20 basic_format_args has no deduction guide added

See also

(哋它亢++20)
class template that provides access to a formatting argument for user-defined formatters
(class template)