假设我有一个
std::map<std::string, int>
。是否可以使用它的 at
方法与 std::string_view
一起使用?下面是代码片段:std::string_view key{ "a" };
std::map<std::string, int> tmp;
tmp["a"] = 0;
auto result = tmp.at(key);
这是来自clang 12.0的输出:
错误:调用'at'的成员函数无匹配项
auto result = tmp.at(key);
std::string_view
在 C++17 中被引入。 - Remy Lebeau