WPILibC++ 2027.0.0-alpha-3
Loading...
Searching...
No Matches
compile.h File Reference
#include <iterator>
#include "format.h"

Go to the source code of this file.

Classes

class  compiled_string
 
struct  is_compiled_string< S >
 
class  static_format_result< N >
 

Namespaces

namespace  detail
 Converts a string literal into a format string that will be parsed at compile time and converted into efficient formatting code.
 

Macros

#define FMT_COMPILE(s)
 Converts a string literal s into a format string that will be parsed at compile time and converted into efficient formatting code.
 
#define FMT_STATIC_FORMAT(fmt_str, ...)
 Formats arguments according to the format string fmt_str and produces a string of the exact required size at compile time.
 

Functions

template<typename T , typename... Tail>
constexpr auto detail::first (const T &value, const Tail &...) -> const T &
 
template<typename OutputIt , typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
FMT_BEGIN_EXPORT auto format_to_n (OutputIt out, size_t n, const S &fmt, T &&... args) -> format_to_n_result< OutputIt >
 
template<typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
FMT_CONSTEXPR20 auto formatted_size (const S &fmt, T &&... args) -> size_t
 
template<typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
void print (std::FILE *f, const S &fmt, T &&... args)
 
template<typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
void print (const S &fmt, T &&... args)
 

Macro Definition Documentation

◆ FMT_COMPILE

#define FMT_COMPILE ( s)
Value:
#define FMT_STRING(s)
Constructs a legacy compile-time format string from a string literal s.
Definition format.h:4239

Converts a string literal s into a format string that will be parsed at compile time and converted into efficient formatting code.

Requires C++17 constexpr if compiler support.

Example:

// Converts 42 into std::string using the most efficient method and no
// runtime format string processing.
std::string s = fmt::format(FMT_COMPILE("{}"), 42);

◆ FMT_STATIC_FORMAT

#define FMT_STATIC_FORMAT ( fmt_str,
... )
Value:
fmt::static_format_result< \
fmt::formatted_size(FMT_COMPILE(fmt_str), __VA_ARGS__) + 1>( \
FMT_COMPILE(fmt_str), __VA_ARGS__)
#define FMT_COMPILE(s)
Converts a string literal s into a format string that will be parsed at compile time and converted in...
Definition compile.h:39

Formats arguments according to the format string fmt_str and produces a string of the exact required size at compile time.

Both the format string and the arguments must be compile-time expressions.

The resulting string can be accessed as a C string via c_str() or as a fmt::string_view via str().

Example:

// Produces the static string "42" at compile time.
static constexpr auto result = FMT_STATIC_FORMAT("{}", 42);
const char* s = result.c_str();

Function Documentation

◆ format_to_n()

template<typename OutputIt , typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
FMT_BEGIN_EXPORT auto format_to_n ( OutputIt out,
size_t n,
const S & fmt,
T &&... args ) -> format_to_n_result<OutputIt>

◆ formatted_size()

template<typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
FMT_CONSTEXPR20 auto formatted_size ( const S & fmt,
T &&... args ) -> size_t

◆ print() [1/2]

template<typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
void print ( const S & fmt,
T &&... args )

◆ print() [2/2]

template<typename S , typename... T, FMT_ENABLE_IF(is_compiled_string< S >::value) >
void print ( std::FILE * f,
const S & fmt,
T &&... args )