WPILibC++ 2025.2.1
Loading...
Searching...
No Matches
dynamic_format_arg_store< Context > Class Template Reference

A dynamic list of formatting arguments with storage. More...

#include <fmt/args.h>

Public Member Functions

constexpr dynamic_format_arg_store ()=default
 
 operator basic_format_args< Context > () const
 
template<typename T >
void push_back (const T &arg)
 Adds an argument into the dynamic store for later passing to a formatting function.
 
template<typename T >
void push_back (std::reference_wrapper< T > arg)
 Adds a reference to the argument into the dynamic store for later passing to a formatting function.
 
template<typename T >
void push_back (const detail::named_arg< char_type, T > &arg)
 Adds named argument into the dynamic store for later passing to a formatting function.
 
void clear ()
 Erase all elements from the store.
 
void reserve (size_t new_cap, size_t new_cap_named)
 Reserves space to store at least new_cap arguments including new_cap_named named arguments.
 
size_t size () const noexcept
 Returns the number of elements in the store.
 

Friends

class basic_format_args< Context >
 

Detailed Description

template<typename Context>
class dynamic_format_arg_store< Context >

A dynamic list of formatting arguments with storage.

It can be implicitly converted into fmt::basic_format_args for passing into type-erased formatting functions such as fmt::vformat.

Constructor & Destructor Documentation

◆ dynamic_format_arg_store()

template<typename Context >
dynamic_format_arg_store< Context >::dynamic_format_arg_store ( )
constexprdefault

Member Function Documentation

◆ clear()

template<typename Context >
void dynamic_format_arg_store< Context >::clear ( )
inline

Erase all elements from the store.

◆ operator basic_format_args< Context >()

template<typename Context >
dynamic_format_arg_store< Context >::operator basic_format_args< Context > ( ) const
inline

◆ push_back() [1/3]

template<typename Context >
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( const detail::named_arg< char_type, T > & arg)
inline

Adds named argument into the dynamic store for later passing to a formatting function.

std::reference_wrapper is supported to avoid copying of the argument. The name is always copied into the store.

◆ push_back() [2/3]

template<typename Context >
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( const T & arg)
inline

Adds an argument into the dynamic store for later passing to a formatting function.

Note that custom types and string types (but not string views) are copied into the store dynamically allocating memory if necessary.

Example:

fmt::dynamic_format_arg_store<fmt::format_context> store;
store.push_back(42);
store.push_back("abc");
store.push_back(1.5f);
std::string result = fmt::vformat("{} and {} and {}", store);

◆ push_back() [3/3]

template<typename Context >
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( std::reference_wrapper< T > arg)
inline

Adds a reference to the argument into the dynamic store for later passing to a formatting function.

Example:

fmt::dynamic_format_arg_store<fmt::format_context> store;
char band[] = "Rolling Stones";
store.push_back(std::cref(band));
band[9] = 'c'; // Changing str affects the output.
std::string result = fmt::vformat("{}", store);
// result == "Rolling Scones"

◆ reserve()

template<typename Context >
void dynamic_format_arg_store< Context >::reserve ( size_t new_cap,
size_t new_cap_named )
inline

Reserves space to store at least new_cap arguments including new_cap_named named arguments.

◆ size()

template<typename Context >
size_t dynamic_format_arg_store< Context >::size ( ) const
inlinenoexcept

Returns the number of elements in the store.

Friends And Related Symbol Documentation

◆ basic_format_args< Context >

template<typename Context >
friend class basic_format_args< Context >
friend

The documentation for this class was generated from the following file: