powerd++  0.4.4
Public Member Functions | Private Attributes | List of all members
utility::Formatter< BufSize > Class Template Reference

A formatting wrapper around string literals. More...

#include <utility.hpp>

Public Member Functions

constexpr Formatter (char const *const fmt)
 Construct from string literal.
 
template<typename... ArgTs>
std::string operator() (ArgTs const &... args) const
 Returns a formatted string. More...
 

Private Attributes

const char *const fmt
 Pointer to the string literal.
 

Detailed Description

template<size_t BufSize>
class utility::Formatter< BufSize >

A formatting wrapper around string literals.

Overloads operator (), which treats the string as a printf formatting string, the arguments represent the data to format.

In combination with the literal _fmt, it can be used like this:

std::cout << "%-15.15s %#018p\n"_fmt("Address:", this);
Template Parameters
BufSizeThe buffer size for formatting, resulting strings cannot grow beyond BufSize - 1

Member Function Documentation

◆ operator()()

template<size_t BufSize>
template<typename... ArgTs>
std::string utility::Formatter< BufSize >::operator() ( ArgTs const &...  args) const
inline

Returns a formatted string.

Template Parameters
ArgTsVariadic argument types
Parameters
argsVariadic arguments
Returns
An std::string formatted according to fmt

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