ALib C++ Library
Library Version: 2510 R0
Documentation generated by doxygen
Loading...
Searching...
No Matches
alib::strings::APPENDABLES::TStdFormat< TChar, TArgs > Struct Template Reference

Description:

template<typename TChar, typename... TArgs>
struct alib::strings::APPENDABLES::TStdFormat< TChar, TArgs >

This struct enables the use of C++20 function std::format - and with that any adaption of custom types - to be directly appendable to class TAString, without the need of creating an intermediate temporary std::string.

For that, this struct stores the format string and a tuple of decayed formatting arguments. With a corresponding specialization of struct AppendableTraits, the formatted output is produced using C++20's std::vformat_to and a std::back_insert_iterator that appends characters directly to an AString.

Note
C++20 supports formatting only on character types char and wchar_t. With that, the specializations of AppendableTraits are likewise only defined for these concrete character types. If you compile ALib to switch the default character type, for example, by using compiler symbol ALIB_CHARACTERS_SIZEOF_WCHAR to change the default size (which is defined by the compiler !), then appending this type TStdFormat might not be available.
For the same reason, the alias definitions of this struct, namely
use these concrete character types, instead of the "logical" types alib::nchar and alib::wchar.
See also
Chapter 9. C++20 std::format of the Programmer's Manual of the module ALib Strings.
Template Parameters
TCharThe character type of the TAString and the format string.
TArgsVariadic template parameters representing the types of the formatting arguments.

Definition at line 664 of file ALib.Compatibility.StdStrings.H.

#include <ALib.Compatibility.StdStrings.H>

Public Field Index:

std::tuple< std::decay_t< TArgs >... > arguments
 The variadic arguments given construction. Will be passed to std::format.
 
TString< TChar > format
 The format string given construction. Will be passed to std::format.
 

Public Method Index:

 TStdFormat (const TString< TChar > &formatString, TArgs &&... args)
 

Field Details:

◆ arguments

template<typename TChar, typename... TArgs>
std::tuple<std::decay_t<TArgs>...> alib::strings::APPENDABLES::TStdFormat< TChar, TArgs >::arguments

The variadic arguments given construction. Will be passed to std::format.

Definition at line 669 of file ALib.Compatibility.StdStrings.H.

◆ format

template<typename TChar, typename... TArgs>
TString<TChar> alib::strings::APPENDABLES::TStdFormat< TChar, TArgs >::format

The format string given construction. Will be passed to std::format.

Definition at line 666 of file ALib.Compatibility.StdStrings.H.

Constructor(s) / Destructor Details:

◆ TStdFormat()

template<typename TChar, typename... TArgs>
alib::strings::APPENDABLES::TStdFormat< TChar, TArgs >::TStdFormat ( const TString< TChar > & formatString,
TArgs &&... args )
inline

Constructor. Uses perfect forwarding and stores decayed copies of the arguments.

Parameters
formatStringStored in format.
argsStored in arguments.

Definition at line 674 of file ALib.Compatibility.StdStrings.H.


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