std::format
Use case
Type-safe printf-style formatting.
Explanation
std::format combines printf convenience with type safety.
Code
#include <cstdint>
#include <format>
#include <iostream>
int main() {
uint64_t addr = 0x10001000;
const char *name = "_main";
std::string s = std::format("Symbol '{}' at {:#x}", name, addr);
std::cout << s << "\n";
return 0;
}
Output
$ ./src/c++20/build/std-format
Symbol '_main' at 0x10001000