We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1577625 commit 193cca8Copy full SHA for 193cca8
libs/cpp.wiki
@@ -304,6 +304,28 @@ cout << format("%s %d") % "price" % 1234;
304
// price 1234
305
</source>
306
307
+<h4>fmt</h4>
308
+
309
+Home:[https://github.com/fmtlib/fmt]
310
311
+这是一个轻量级、类型安全、高性能的字符串格式化库。它也可以用来替代 C++ 标准库中的 IOStreams。
312
313
+代码示例
314
+<source lang="cpp">
315
+#include <string>
316
+#include <fmt/format.h>
317
318
+// 使用 Python 的格式化语法
319
+fmt::print("Hello, {}!", "world");
320
+// 使用 printf 的格式化语法
321
+fmt::printf("Hello, %s!", "world");
322
+// 使用序号参数,
323
+std::string s = fmt::format("{0} {1} {0}", "Hello", "world");
324
+// 使用命名参数
325
+fmt::print("Hello, {name}! The answer is {number}. Goodbye, {name}.",
326
+ fmt::arg("name", "World"), fmt::arg("number", 42));
327
+</source>
328
329
=== 2.3.3 正则表达式 ===
330
331
<h4>PCRE(Perl Compatible Regular Expressions)</h4>
0 commit comments