fmtlib.fmt
importA modern formatting library for C++, exposed as C++23 module fmt
import fmt;
mcpp add fmtlib.fmt@12.2.0
用法
来自本仓库自己的测试项目 —— CI 真的编译并运行过,不是为了网站写的。
// Behavioral test: consume {fmt}'s compiled implementation through the C++23
// module `fmt` (`import fmt;`, no #include) and assert the results. Exercises
// src/format.cc via the module unit's tail includes — not just header inlines.
// Returns non-zero on any mismatch.
import std;
import fmt;
int main() {
std::string a = fmt::format("{} + {} = {}", 2, 3, 2 + 3);
std::string b = fmt::format("{:08.3f}", 3.14159);
std::string c = fmt::format("{0}-{1}-{0}", "x", "y");
std::string d = fmt::format("{:#x}", 255);
bool ok = a == "2 + 3 = 5"
&& b == "0003.142"
&& c == "x-y-x"
&& d == "0xff";
return ok ? 0 : 1;
}
tests/examples/fmtlib.fmt/tests/format_test.cpp · 项目 tests/examples/fmtlib.fmt
构建
- modules
fmt- targets
fmt (lib)- language
c++23- import std
- yes
- include dirs
*/include, */src
源文件 (1)
mcpp_generated/fmt_module.cppm
生成的文件
mcpp_generated/fmt_module.cppm
版本
| 版本 | 平台 | 镜像 | sha256 |
|---|---|---|---|
12.2.0 最新 |
LinuxWindowsmacOS | 源站 | 8b852bb5aa6e… |