我试图创建一个hash_set
持有不同的文件的名称,就像这样:如何正确使用的hash_set在C++
struct eq {
bool operator()(const char* c1, const char* c2) {
return strcmp(c1, c2) == 0;
}
};
int main(int argc, char* argv[])
{
hash_set<const char*, hash<const char*>, eq> fileNames;
return 0;
}
,给了我很多编译器错误的沿着线:
Error 1 error C2039 : 'bucket_size' : is not a member of 'std::hash<const char *>' C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xhash 264 1 Tests
Error 2 error C2065 : 'bucket_size' : undeclared identifier C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xhash 264 1 Tests
Error 3 error C2039 : 'value_type' : is not a member of 'eq' C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 419 1 Tests
Error 4 error C2146 : syntax error : missing ';' before identifier 'value_type' C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 419 1 Tests
Error 5 error C4430 : missing type specifier - int assumed.Note : C++ does not support default - int C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 419 1 Tests
Error 6 error C2602 : 'std::allocator_traits<_Alloc>::value_type' is not a member of a base class of 'std::allocator_traits<_Alloc>' C :\Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 419 1 Tests
Error 7 error C2146 : syntax error : missing ',' before identifier 'value_type' C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 242 1 Tests
Error 8 error C2065 : 'value_type' : undeclared identifier C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 242 1 Tests
Error 9 error C2059 : syntax error : '>' C : \Program Files(x86)\xDev\Microsoft Visual Studio 12.0\VC\include\xmemory0 242 1 Tests
...
什么是'hash_set'实际上?你错过了包含你的代码的东西吗? –
是的我包括: #include。 hash_set是我可以发现视觉工作室认可的唯一的东西。 –
你从哪里得到的? 'hash_set'不是标准的,所以它必须来自其他库。 C++ 11的'unorderd_set'如何?我不认为我们可以在不了解你的'hash_set'的情况下提供帮助。 –