【发布时间】:2014-04-10 19:36:37
【问题描述】:
我有一段代码在 MSVC 上运行良好,但无法用 clang++ 编译
void MyCass::someMethod()
{
std::wstring key(...);
auto& refInstance = m_map.find(key); // error here
}
其中 m_map 被定义为
std::map<const std::wstring, std::shared_ptr<IInterface>> m_map;
和clang抱怨
non-const lvalue reference cannot bind to incompatible temporary
我有点理解正在创建一个临时的,但不知道如何去解决这个问题。有什么想法吗?
【问题讨论】:
标签: c++ compiler-errors clang