std::tr1::unordered_set problem in GCC 4.1.2
Hi,
I am coding my first major C++ program and I have some problems with
std::tr1::unordered_set which I haven't used before and I help I can get
some help here. The platform is GCC version 4.1.2 on a linux box.
The compile error message is very long and I don't understand how to
read it.
Thank you for any help.
Regards
Martin M. Pedersen
Here are some simple code which I hope shows my problem:
=traxboard.h=
class Traxboard {
public:
Traxboard();
bool operator==(const Traxboard& another) const;
void operator&();
int getHash() const;
}
=openingbook.h=
#include <tr1/unordered_set>
#include "traxboard.h"
struct TraxboardHash
{
std::size_t operator()(const Traxboard& tb)
{
return tb.getHash();
}
};
struct TraxboardCompare
{
bool operator()(const Traxboard& tb1, const Traxboard& tb2) const
{
return (tb1.getHash()<tb2.getHash());
}
};
class OpeningBook {
public:
OpeningBook();
private:
std::tr1::unordered_set<Traxboard, TraxboardHash, TraxboardCompare>
traxboards;
};
===============================================================
And here comes the compile error message:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/tr1/hashtable:
In member function ?void std::tr1::hashtable<Key, Value, Allocator,
ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code,
constant_iterators,
unique_keys>::m_deallocate_node(Internal::hash_node<Value,
cache_hash_code>*) [with Key = Traxboard, Value = Traxboard, Allocator =
std::allocator<Traxboard>, ExtractKey = Internal::identity<Traxboard>,
Equal = TraxboardCompare, H1 = TraxboardHash, H2 =
Internal::mod_range_hashing, H = Internal::default_ranged_hash,
RehashPolicy = Internal::prime_rehash_policy, bool cache_hash_code =
false, bool constant_iterators = true, bool unique_keys = true]?:
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/tr1/hashtable:1341:
instantiated from ?void std::tr1::hashtable<Key, Value, Allocator,
ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code,
constant_iterators,
unique_keys>::m_deallocate_nodes(Internal::hash_node<Value,
cache_hash_code>**, typename Allocator::size_type) [with Key =
Traxboard, Value = Traxboard, Allocator = std::allocator<Traxboard>,
ExtractKey = Internal::identity<Traxboard>, Equal = TraxboardCompare, H1
= TraxboardHash, H2 = Internal::mod_range_hashing, H =
Internal::default_ranged_hash, RehashPolicy =
Internal::prime_rehash_policy, bool cache_hash_code = false, bool
constant_iterators = true, bool unique_keys = true]?
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/tr1/hashtable:1896:
instantiated from ?void std::tr1::hashtable<Key, Value, Allocator,
ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code,
constant_iterators, unique_keys>::clear() [with Key = Traxboard, Value =
Traxboard, Allocator = std::allocator<Traxboard>, ExtractKey =
Internal::identity<Traxboard>, Equal = TraxboardCompare, H1 =
TraxboardHash, H2 = Internal::mod_range_hashing, H =
Internal::default_ranged_hash, RehashPolicy =
Internal::prime_rehash_policy, bool cache_hash_code = false, bool
constant_iterators = true, bool unique_keys = true]?
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/tr1/hashtable:1494:
instantiated from ?std::tr1::hashtable<Key, Value, Allocator,
ExtractKey, Equal, H1, H2, H, RehashPolicy, cache_hash_code,
constant_iterators, unique_keys>::~hashtable() [with Key = Traxboard,
Value = Traxboard, Allocator = std::allocator<Traxboard>, ExtractKey =
Internal::identity<Traxboard>, Equal = TraxboardCompare, H1 =
TraxboardHash, H2 = Internal::mod_range_hashing, H =
Internal::default_ranged_hash, RehashPolicy =
Internal::prime_rehash_policy, bool cache_hash_code = false, bool
constant_iterators = true, bool unique_keys = true]?
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/tr1/unordered_set:61:
instantiated from here
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/tr1/hashtable:1322:
error: no matching function for call to
?std::allocator<Traxboard>::destroy(bool)?
/usr/lib/gcc/i486-linux-gnu/4.1.2/../../../../include/c++/4.1.2/ext/new_allocator.h:107:
note: candidates are: void __gnu_cxx::new_allocator<_Tp>::destroy(_Tp*)
[with _Tp = Traxboard]
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]