Wikipedia:Reference desk/Archives/Computing/2016 February 3

= February 3 =

more STL questions
First of all, thank you to everyone who helped me yesterday; I really appreciate it. Now, why doesn't the following code compile?

The compiler gives a whole bunch of error messages starting with

Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/unordered_map:386:17: error: no matching function for call to object of type 'const std::__1::equal_to >' {return static_cast(*this)(__x);} ^19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)19:59, 3 February 2016 (UTC)~ /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/__hash_table:2014:21: note: in instantiation of member function 'std::__1::__unordered_map_hasher, std::__1::__hash_value_type, double>, std::__1::equal_to >, true>::operator' requested here size_t __hash = hash_function(__k);

I don't understand these messages, can anyone advise? Thanks, Robinh (talk) 19:59, 3 February 2016 (UTC)


 * Don't use Nimur's code; it is wrong (and causing compilation errors) for reasons unrelated to your problem. To use unordered_map, just replace map with unordered_map in your code and provide a hash function for vector&lt;int&gt;. In the previous thread I linked to a couple of possible hash functions and an explanation of how to use custom hash functions with unordered_map. -- BenRG (talk) 03:06, 4 February 2016 (UTC)