I used the hash_set container when I wrote a program under Ubuntu today. There was a problem. Here I will record it. Let's talk about it. The hash _ * series, such as hash_map and hash_set, have been deprecated, c ++ 11 is replaced by unordered_map and unordered_set. However, I use g ++ 4.6.1 To warn that the C ++ 11 feature is experimental and seems to be fully supported by 4.8. So I switched to hash_set and wrote the following program:
#include <iostream>#include <string>#include
Direct error: Error: 'hash _ set' was not declared in this scope
It is strange that the header file is included, and the original hash_set is included in the namespace _ gnu_cxx.
Using namespace _ gnu_cxx is compiled and jumped to hashtable. in the source code of H, the hasher function is shown as follows: Error: no match for call to '(const hasher {aka const _ gnu_cxx: Hash <STD :: basic_string <char >>}) (const key_type &)'
This problem should be due to the fact that the hash function does not support the string class. However, I did not know how to solve this problem, and I found it online for a long time, find a solution on the Internet, as shown in the following code:
#include <iostream>#include <string>#include Finally, it can run successfully. The added part is mainly to convert the string class to a char * pointer before it can be hashed.
PS: this is not a big problem. If you encounter it by accident, record it here.