FastLED 3.10.6
Loading...
Searching...
No Matches

◆ printf() [2/2]

template<typename... Args>
void fl::printf ( const char * format,
const Args &... args )

Printf-like formatting function that prints directly to the platform output.

Parameters
formatFormat string with placeholders like "%d", "%s", "%f" etc.
argsArguments 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:

fl::printf("Value: %d, Name: %s", 42, "test");
fl::printf("Float: %.2f", 3.14159);
int* ptr = &value;
fl::printf("Pointer: %p", ptr);
constexpr int type_rank< T >::value
void printf(const char *format) FL_NO_EXCEPT
Parameters
formatFormat string with placeholders like "%d", "%s", "%f" etc.
argsArguments 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:

fl::printf("Value: %d, Name: %s", 42, "test");
fl::printf("Float: %.2f", 3.14159);

Definition at line 961 of file stdio.h.

961 {
962 sstream stream;
964 fl::print(stream.str().c_str());
965}
const char * c_str() const FL_NO_EXCEPT
string str() const FL_NO_EXCEPT
Definition strstream.h:43
void format_impl(sstream &stream, const char *format) FL_NO_EXCEPT
Definition stdio.h:855
void print(const char *str)
fl::string format(const char *fmt)
Format with no arguments.
Definition format.h:439
corkscrew_args args
Definition old.h:149

References args, fl::basic_string::c_str(), FL_NO_EXCEPT, format(), fl::printf_detail::format_impl(), print(), and fl::sstream::str().

+ Here is the call graph for this function: