fmt
Loading...
Searching...
No Matches
fmt::literals Namespace Referenceexport

Functions

template<detail::FixedString Str>
constexpr auto operator""_cf () -> CompiledFormatString< Str >
template<detail::FixedString S>
constexpr auto operator""_a ()

Detailed Description

Converts a string literal into a compiled format string.

The format string is parsed at compile time and turned into formatting code, so no run-time format string processing remains. This is faster than an ordinary format string at the cost of code size, and it requires a literal.

Returns
a compiled_format_string for the literal.

Example:

using namespace fmt::literals;
// No run-time format string processing.
std::string s = fmt::format("{}"_cf, 42);

Function Documentation

◆ operator""_a()

template<detail::FixedString S>
auto fmt::literals::operator""_a ( )
constexprexport

User-defined literal equivalent of fmt::arg, but with compile-time checks.

Example:

using namespace fmt::literals;
fmt::print("The answer is {answer}.", "answer"_a=42);