Printf-like formatting function that prints directly to the platform output.
- Parameters
-
| format | Format string with placeholders like "%d", "%s", "%f" etc. |
| args | Arguments to format |
Supported format specifiers:
- d, i: integers (all integral types)
- u: unsigned integers
- o: octal integers
- f: floating point numbers
- s: strings (const char*, fl::string)
- c: characters
- x: hexadecimal (lowercase)
- X: hexadecimal (uppercase)
- p: pointers (formatted as 0x... hex)
- %%: literal % character
Generic placeholder:
- {}: formats the next argument by picking the natural specifier for its C++ type, so callers do not have to choose between d / u / ld / s / p or call .c_str(). Supported argument types are the same set the % specifiers support: all integral types (d), bool (as "true"/"false"), char (as a character, c), float/double (f), const char* and fl::string / fl::string_view (s), pointers (p), and unscoped enums (as their underlying integer). Scoped enums (enum class) do not compile through {} or d; cast at the call site. Passing any other type to {} is a compile error - {} deliberately does not fall back to a generic streaming path, to keep code size flat.
- {{: literal { character
- }}: literal } character
- A lone { or } that is not part of the above passes through literally.
- A {} with no remaining argument emits <missing_arg>, matching the behavior of a % specifier with no remaining argument.
Example usage:
constexpr int type_rank< T >::value
void printf(const char *format) FL_NO_EXCEPT
- Parameters
-
| format | Format string with placeholders like "%d", "%s", "%f" etc. |
| args | Arguments to format |
Supported format specifiers:
- d, i: integers (all integral types)
- u: unsigned integers
- o: octal integers
- f: floating point numbers
- s: strings (const char*, fl::string)
- c: characters
- x: hexadecimal (lowercase)
- X: hexadecimal (uppercase)
- p: pointers (formatted as 0x... hex)
- %%: literal % character
Generic placeholder:
- {}: formats the next argument by picking the natural specifier for its C++ type, so callers do not have to choose between d / u / ld / s / p or call .c_str(). Supported argument types are the same set the % specifiers support: all integral types (d), bool (as "true"/"false"), char (as a character, c), float/double (f), const char* and fl::string / fl::string_view (s), pointers (p), and unscoped enums (as their underlying integer). Scoped enums (enum class) do not compile through {} or d; cast at the call site. Passing any other type to {} is a compile error - {} deliberately does not fall back to a generic streaming path, to keep code size flat.
- {{: literal { character
- }}: literal } character
- A lone { or } that is not part of the above passes through literally.
- A {} with no remaining argument emits <missing_arg>, matching the behavior of a % specifier with no remaining argument.
Example usage:
Definition at line 961 of file stdio.h.
961 {
965}
const char * c_str() const FL_NO_EXCEPT
string str() const FL_NO_EXCEPT
void format_impl(sstream &stream, const char *format) FL_NO_EXCEPT
void print(const char *str)
fl::string format(const char *fmt)
Format with no arguments.
References args, fl::basic_string::c_str(), FL_NO_EXCEPT, format(), fl::printf_detail::format_impl(), print(), and fl::sstream::str().