fmt 란
- C++ formatting library
- Python 과 유사하게 format syntax
- C++20 부터 std::format 으로 사용 가능
예시
#include <fmt/core.h>
#include <iostream>
int main () {
auto str = fmt::format("in {}s\n", 47);
std::cout << str; // in 47s
}
Printing
#include <fmt/core.h>
int main () {
fmt::print("in {}s\n", 47); // in 47s
fmt::print(stderr, "error: {}\n", 404); // error: 404
}
Argument Placeholder
#include <fmt/core.h>
int main () {
int i = 7;
double d = 3.4;
std::string s = "text";
fmt::print("fast {} output\n", s);
fmt::print("{} times\n", 47);
fmt::print("{} of {}\n", i, 9);
fmt::print("{}|{}|{}\n", d, i, 5);
fmt::print("escaped {{ & }}\n");
}
출처 :
https://hackingcpp.com/cpp/libs/fmt.html