And*_*res 4 c++ format c++20 fmt
我已经看到 std::format 是多么有用。但是每次我尝试将它包含在 C++20 中时,它都不起作用。它显然已经包含在其图书馆中,但没有出现,而且网上也没有任何信息。甚至 cppreference 也有它的示例,但它甚至不能在其在线编译器上运行。我附上了它的一个片段。
你们有没有人知道如何在没有超级复杂的 GitHub 导入库的情况下使其工作。我主要在 VisualStudio 上工作。
#include <iostream>
#include <format>
int main() {
std::cout << std::format("Hello {}!\n", "world");
}
Run Code Online (Sandbox Code Playgroud)
main.cpp:2:10: fatal error: No such file or directory
2 | #include <format>
| ^~~~~~~~
compilation terminated.
Run Code Online (Sandbox Code Playgroud)
截至 2020 年 7 月,没有任何标准库实现提供std::format. 在他们这样做之前,您可以使用{fmt} 库 std::format基于:
#include <iostream>
#include <fmt/core.h>
int main() {
std::cout << fmt::format("Hello {}!\n", "world");
}
Run Code Online (Sandbox Code Playgroud)