如何从输出中删除 {}?
#include <iostream>
#include <vector>
#include <fmt/format.h>
#include <fmt/ranges.h>
int main () {
std::vector<int> v = {1,2,3};
std::string s = fmt::format("{}", v);
std::cout << s << '\n'; // output : {1, 2, 3}
return 0;
}
如何在上述代码的输出中删除 '{' 和 '}' 并仅打印:1, 2, 3
std::cout << s.substr(1, s.size()-2) << '\n';
- Remy Lebeau{
和后缀}
在ranges.h
头文件中是硬编码的。链接 - Daniel Langr