以下代码在最新的编译器上无法构建(g++-5.3,clang++-3.7)。
#include <map>
#include <functional>
#include <experimental/string_view>
void f()
{
using namespace std;
using namespace std::experimental;
map<string, int> m;
string s = "foo";
string_view sv(s);
m.find(sv);
}
clang返回的错误:
error: no matching member function for call to 'find'
m.find(sv);
~~^~~~
但是,find
不应该能够使用可比类型吗?Cppreference提到了以下重载:
template< class K > iterator find( const K& x );
使用boost::string_ref
也会出现相同的错误。