69得票5回答
GCC是否支持C++20的std::format?

如果不支持,你知道哪个编译器或版本可以吗? 查看cppreference/format。

28得票2回答
如何使用 C++20 的 std::format?

C++20引入了std::format。与printf或std::cout相比,它有什么优势? 我该如何使用它?能否举个例子?

26得票6回答
C++字符串格式化如Python中的"{}".format。

我希望找到一种快速整洁的方式以漂亮的表格格式打印,使单元格正确对齐。 C++中是否有一种方便的方法可以创建特定长度的子字符串字符串,类似于Python format的功能?"{:10}".format("some_string")

26得票2回答
无法在C++20中使用std::format。

我一直在尝试使用C++20中包含的std::format函数。据我所知,clang 14应该支持此功能,但由于某种原因,我收到以下错误:no member named 'format' in namespace 'std'。根据cppreference的编译器支持图表,clang应该支持文本格...

24得票2回答
用户定义类型的std::format?

在C++20中,如何使用户自定义类型与std::format兼容?例如,假设我有一个名为Point的类型: struct Point { int x; int y; }; 使用其定义了operator<<的: inline std::ostream&...

20得票2回答
如何创建一个函数,它将其参数传递给fmt::format并保持类型安全性?

我有两个广泛相关的问题。 我想要创建一个函数,将参数转发到fmt::format (以后当支持增加时也可以转发到std::format)。类似于这样:#include <iostream> #include <fmt/core.h> constexpr auto my...

19得票2回答
格式不匹配,找不到文件或目录。

我尝试使用C++的格式化工具(std::format)。我尝试编译这个简单的程序:#include <format> int main() { std::cout << std::format("{}, {}", "Hello wo...

17得票1回答
使用fmt库将vector<int>转换为字符串

如何从输出中删除 {}?#include &lt;iostream&gt; #include &lt;vector&gt; #include &lt;fmt/format.h&gt; #include &lt;fmt/ranges.h&gt; int main () { std::ve...

16得票1回答
libfmt和std::format有什么区别?

我知道c++20格式化提案是libfmt的一部分的正式化,而libfmt是其规范实现。但据我了解,libfmt提供了超出c++20标准规定的其他功能。这些额外的功能是什么? 另外,主要的编译器厂商是只包含libfmt的一个子集还是重新实现它?

13得票1回答
如何使用fmt库格式化带有小数逗号的浮点数?

我想使用fmt库来格式化浮点数。 我尝试使用逗号作为小数点格式化浮点数,但是没有成功:#include &lt;iostream&gt; #include &lt;fmt/format.h&gt; #include &lt;fmt/locale.h&gt; struct numpunct :...