使用库的 C++ 代码fmt
按预期运行:
#include <fmt/format.h>
#include <fmt/ranges.h>
#include <vector>
int main() {
std::vector<int> v{4, 2, 7};
fmt::println("{}", v);
}
我尝试将标准print
头与 g++-14 一起使用:
#include <print>
#include <vector>
void test() {
std::vector<int> v{4, 2, 7};
std::println("{}", v);
}
无法使用巨大的模板进行编译。有办法解决吗?
您的标准库必须支持P2585才能
std::format
在 上使用std::vector
,并且根据libstdc++ 实现状态页,尚不支持 P2585,因此您必须等待未来的版本。