2

我想知道 {fmt} 库是否只允许修改包含多个位置参数的字符串中的一个位置参数?

这是我的测试不起作用,{fmt} 文档显示没有解决方案

std::string text = "{name} is {nb} years old and lives in {city}";
try
{
    text = fmt::format(text, fmt::arg("name", "John"));
}
catch (const fmt::format_error::exception &e)
{
    std::cout << e.what() << std::endl;
}

我想得到John is {nb} years old and lives in {city},可以吗?

4

1 回答 1

1

不,引用不存在的论点,无论是否有位置,都是错误的。

于 2020-11-19T23:23:26.280 回答