Classes | Public Member Functions | Private Types | Private Member Functions | Private Attributes | Friends | List of all members
dynamic_format_arg_store< Context > Class Template Reference

#include <args.h>

Classes

struct  need_copy
 

Public Member Functions

void clear ()
 
constexpr dynamic_format_arg_store ()=default
 
template<typename T >
void push_back (const detail::named_arg< char_type, T > &arg)
 
template<typename T >
void push_back (const T &arg)
 
template<typename T >
void push_back (std::reference_wrapper< T > arg)
 
void reserve (size_t new_cap, size_t new_cap_named)
 

Private Types

using char_type = typename Context::char_type
 
template<typename T >
using stored_type = conditional_t< std::is_convertible< T, std::basic_string< char_type > >::value &&!detail::is_reference_wrapper< T >::value, std::basic_string< char_type >, T >
 

Private Member Functions

auto data () const -> const basic_format_arg< Context > *
 
template<typename T >
void emplace_arg (const detail::named_arg< char_type, T > &arg)
 
template<typename T >
void emplace_arg (const T &arg)
 
auto get_types () const -> unsigned long long
 

Private Attributes

std::vector< basic_format_arg< Context > > data_
 
detail::dynamic_arg_list dynamic_args_
 
std::vector< detail::named_arg_info< char_type > > named_info_
 

Friends

class basic_format_args< Context >
 

Detailed Description

template<typename Context>
class dynamic_format_arg_store< Context >

\rst A dynamic version of fmt::format_arg_store. It's equipped with a storage to potentially temporary objects which lifetimes could be shorter than the format arguments object.

It can be implicitly converted into ~fmtbasic_format_args for passing into type-erased formatting functions such as ~fmtvformat. \endrst

Definition at line 75 of file args.h.

Member Typedef Documentation

◆ char_type

template<typename Context >
using dynamic_format_arg_store< Context >::char_type = typename Context::char_type
private

Definition at line 82 of file args.h.

◆ stored_type

template<typename Context >
template<typename T >
using dynamic_format_arg_store< Context >::stored_type = conditional_t< std::is_convertible<T, std::basic_string<char_type> >::value && !detail::is_reference_wrapper<T>::value, std::basic_string<char_type>, T>
private

Definition at line 102 of file args.h.

Constructor & Destructor Documentation

◆ dynamic_format_arg_store()

template<typename Context >
constexpr 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

Definition at line 213 of file args.h.

◆ data()

template<typename Context >
auto dynamic_format_arg_store< Context >::data ( ) const -> const basic_format_arg<Context>*
inlineprivate

Definition at line 121 of file args.h.

◆ emplace_arg() [1/2]

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

Definition at line 130 of file args.h.

◆ emplace_arg() [2/2]

template<typename Context >
template<typename T >
void dynamic_format_arg_store< Context >::emplace_arg ( const T &  arg)
inlineprivate

Definition at line 125 of file args.h.

◆ get_types()

template<typename Context >
auto dynamic_format_arg_store< Context >::get_types ( ) const -> unsigned long long
inlineprivate

Definition at line 114 of file args.h.

◆ 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.

Definition at line 201 of file args.h.

◆ push_back() [2/3]

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

\rst 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); \endrst

Definition at line 166 of file args.h.

◆ push_back() [3/3]

template<typename Context >
template<typename T >
void dynamic_format_arg_store< Context >::push_back ( std::reference_wrapper< T >  arg)
inline
\rst
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" \endrst

Definition at line 188 of file args.h.

◆ reserve()

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

\rst Reserves space to store at least new_cap arguments including new_cap_named* named arguments. \endrst

Definition at line 225 of file args.h.

Friends And Related Function Documentation

◆ basic_format_args< Context >

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

Definition at line 112 of file args.h.

Member Data Documentation

◆ data_

template<typename Context >
std::vector<basic_format_arg<Context> > dynamic_format_arg_store< Context >::data_
private

Definition at line 105 of file args.h.

◆ dynamic_args_

template<typename Context >
detail::dynamic_arg_list dynamic_format_arg_store< Context >::dynamic_args_
private

Definition at line 110 of file args.h.

◆ named_info_

template<typename Context >
std::vector<detail::named_arg_info<char_type> > dynamic_format_arg_store< Context >::named_info_
private

Definition at line 106 of file args.h.


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


plotjuggler
Author(s): Davide Faconti
autogenerated on Mon Nov 11 2024 03:23:50