![](https://secure.gravatar.com/avatar/789edbb3a9b9f3f13815d199bfa4c81b.jpg?s=120&d=mm&r=g)
On 14/1/10 19:53, Krzysztof Kosiński wrote:
W dniu 14 stycznia 2010 18:10 użytkownik ~suv <suv-sf@...58...> napisał:
BZR Revision 8976 fails to build on OS X 10.5.8:
At first glance it looks like a bug in <tr1/unordered_set> in your compiler version.
Can you compile the example from the third answer here, to see whether unordered_set works at all? http://stackoverflow.com/questions/1335739/how-to-determine-if-a-list-is-sub...
using the second example from the 3rd answer (Hash Tables):
LeWitt:lists suv$ ll total 24 -rw-r--r--@ 1 suv staff 547 Jan 14 19:57 bit-sets.cpp -rw-r--r--@ 1 suv staff 808 Jan 14 19:56 hash-tables.cpp -rw-r--r--@ 1 suv staff 543 Jan 14 19:57 sorted-lists.cpp LeWitt:lists suv$ make -n hash-tables g++ hash-tables.cpp -o hash-tables LeWitt:lists suv$ make hash-tables
g++ hash-tables.cpp -o hash-tables /usr/include/c++/4.0.0/tr1/hashtable: In copy constructor ‘std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::hashtable(const std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>&) [with Key = int, Value = int, Allocator = std::allocator<int>, ExtractKey = Internal::identity<int>, Equal = std::equal_to<int>, H1 = std::tr1::hash<int>, H2 = Internal::mod_range_hashing, H = Internal::default_ranged_hash, RehashPolicy = Internal::prime_rehash_policy, bool cache_hash_code = false, bool mutable_iterators = false, bool unique_keys = true]’: /usr/include/c++/4.0.0/tr1/unordered_set:56: instantiated from here /usr/include/c++/4.0.0/tr1/hashtable:1045: error: invalid conversion from ‘Internal::hash_node<int, false>*’ to ‘int’ /usr/include/c++/4.0.0/tr1/hashtable:1045: error: initializing argument 1 of ‘typename std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::node* std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::m_allocate_node(const Value&) [with Key = int, Value = int, Allocator = std::allocator<int>, ExtractKey = Internal::identity<int>, Equal = std::equal_to<int>, H1 = std::tr1::hash<int>, H2 = Internal::mod_range_hashing, H = Internal::default_ranged_hash, RehashPolicy = Internal::prime_rehash_policy, bool cache_hash_code = false, bool mutable_iterators = false, bool unique_keys = true]’ /usr/include/c++/4.0.0/tr1/unordered_set:56: instantiated from here /usr/include/c++/4.0.0/tr1/hashtable:1046: error: request for member ‘copy_code_from’ in ‘* tail’, which is of non-class type ‘Internal::hash_node<int, false>*’ /usr/include/c++/4.0.0/tr1/hashtable: In member function ‘typename std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::const_iterator std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::find(const Key&) const [with Key = int, Value = int, Allocator = std::allocator<int>, ExtractKey = Internal::identity<int>, Equal = std::equal_to<int>, H1 = std::tr1::hash<int>, H2 = Internal::mod_range_hashing, H = Internal::default_ranged_hash, RehashPolicy = Internal::prime_rehash_policy, bool cache_hash_code = false, bool mutable_iterators = false, bool unique_keys = true]’: hash-tables.cpp:29: instantiated from here /usr/include/c++/4.0.0/tr1/hashtable:1135: error: passing ‘const std::tr1::hashtable<int, int, std::allocator<int>, Internal::identity<int>, std::equal_to<int>, std::tr1::hash<int>, Internal::mod_range_hashing, Internal::default_ranged_hash, Internal::prime_rehash_policy, false, false, true>’ as ‘this’ argument of ‘typename std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::node* std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::find_node(Internal::hash_node<Value, cache_hash_code>*, const Key&, typename std::tr1::hashtable<Key, Value, Allocator, ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code, mutable_iterators, unique_keys>::hash_code_t) [with Key = int, Value = int, Allocator = std::allocator<int>, ExtractKey = Internal::identity<int>, Equal = std::equal_to<int>, H1 = std::tr1::h
ash<int>, H2 = Internal::mod_range_hashing, H = Internal::default_ranged_hash, RehashPolicy = Internal::prime_rehash_policy, bool cache_hash_code = false, bool mutable_iterators = false, bool unique_keys = true]’ discards qualifiers
make: *** [hash-tables] Error 1 LeWitt:lists suv$
Please bear in mind I don't know anything about C++ myself, nor do I know if I would need any special flags to build that example.
~suv
#include <tr1/unordered_set>
std::tr1::unordered_set<int> create_S() { std::tr1::unordered_set<int> S; S.insert(3); S.insert(2); S.insert(4); S.insert(1); return S; }
std::tr1::unordered_set<int> create_T() { std::tr1::unordered_set<int> T; T.insert(4); T.insert(3); T.insert(5); return T; }
bool includes(const std::tr1::unordered_set<int>& S, const std::tr1::unordered_set<int>& T) { for (std::tr1::unordered_set<int>::const_iterator iter=T.begin(); iter!=T.end(); ++iter) { if (S.find(*iter)==S.end()) { return false; } } return true; }
int main() { std::tr1::unordered_set<int> S=create_S(); std::tr1::unordered_set<int> T=create_T(); return includes(S,T); }