我收到一个错误
error: use of undeclared identifier '__stl_hash_string'
{ return __stl_hash_string( __s.c_str() ); }
在 Mac OS 10.8 上使用 Xcode 4.6.1 编译时。
/ ------下面的代码片段---- /
#ifdef __cplusplus
namespace __gnu_cxx
{
template<>
struct hash<std::string>
{
size_t operator()(const std::string& __s) const
{ return __stl_hash_string( __s.c_str() ); }
};
}
#endif
/ -------------------------------------- / 此代码在 Xcode 3.5 上运行良好Mac OSX 10.7 和 10.6。
我搜索了该__stl_hash_string
方法,发现它存在于文件夹中
/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk/usr/include/c++/4.2.1/ext/hash_fun.h
但是,当我编写示例应用程序以查看是否可以包含此标头时,它失败了。
#include < cstddef >
#include < ext/hash_fun.h >
在第二行给了我一个错误,说不能包含这个标题。我不确定这种方法是否在新环境中被弃用,如果它被弃用,那么替代方法是什么。我请求您帮助解决这个问题。