SoPlex Documentation
Loading...
Searching...
No Matches
dynamic_format_arg_store< Context > Class Template Reference

#include <core.h>

Classes

struct  need_copy
 

Public Member Functions

template<typename T >
void push_back (const T &arg)
 
template<typename T >
void push_back (std::reference_wrapper< T > arg)
 
template<typename T >
void push_back (const detail::named_arg< char_type, T > &arg)
 
void clear ()
 
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
 

Private Member Functions

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

Private Attributes

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

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 1656 of file core.h.

Member Typedef Documentation

◆ char_type

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

Definition at line 1663 of file core.h.

◆ stored_type

template<typename Context >
template<typename T >
using stored_type
private
Initial value:
std::basic_string<char_type>, T>
typename std::conditional< B, T, F >::type conditional_t
Definition core.h:261

Definition at line 1680 of file core.h.

Member Function Documentation

◆ clear()

template<typename Context >
void clear ( )

Erase all elements from the store

Definition at line 1798 of file core.h.

◆ data()

template<typename Context >
const basic_format_arg< Context > * data ( ) const
private

Definition at line 1700 of file core.h.

◆ emplace_arg() [1/2]

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

Definition at line 1709 of file core.h.

References arg(), detail::make_arg(), and detail::unwrap().

◆ emplace_arg() [2/2]

template<typename Context >
template<typename T >
void emplace_arg ( const T & arg)
private

Definition at line 1704 of file core.h.

References arg(), and detail::make_arg().

◆ get_types()

template<typename Context >
unsigned long long get_types ( ) const
private

Definition at line 1693 of file core.h.

References detail::has_named_args_bit, and detail::is_unpacked_bit.

◆ push_back() [1/3]

template<typename Context >
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. std::reference_wrapper is supported to avoid copying of the argument.

Definition at line 1786 of file core.h.

References arg(), detail::const_check(), and dynamic_arg_list::push().

◆ push_back() [2/3]

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

\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 1743 of file core.h.

References arg(), detail::const_check(), dynamic_arg_list::push(), and detail::unwrap().

◆ push_back() [3/3]

template<typename Context >
template<typename T >
void push_back ( std::reference_wrapper< T > arg)
\rst
Adds a reference to the argument into the dynamic store for later passing to
a formatting function. Supports named arguments wrapped in
``std::reference_wrapper`` via ``std::ref()``/``std::cref()``.

  Example**::

  fmt::dynamic_format_arg_store<fmt::format_context> store;
  char str[] = "1234567890";
  store.push_back(std::cref(str));
  int a1_val{42};
  auto a1 = fmt::arg("a1_", a1_val);
  store.push_back(std::cref(a1));

Changing str affects the output but only for string and custom types. str[0] = 'X';

std::string result = fmt::vformat("{} and {a1_}"); assert(result == "X234567890 and 42"); \endrst

Definition at line 1772 of file core.h.

References arg().

◆ reserve()

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

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

Definition at line 1810 of file core.h.

References FMT_ASSERT.

Friends And Related Symbol Documentation

◆ basic_format_args< Context >

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

Definition at line 1689 of file core.h.

Member Data Documentation

◆ data_

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

Definition at line 1684 of file core.h.

◆ dynamic_args_

template<typename Context >
detail::dynamic_arg_list dynamic_args_
private

Definition at line 1689 of file core.h.

◆ named_info_

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

Definition at line 1685 of file core.h.