Re: std::tr1::unordered_set problem in GCC 4.1.2
Carl Barron wrote:
Martin M. Pedersen <traxplayer@gmail.com> wrote:
struct TraxboardCompare
{
bool operator()(const Traxboard& tb1, const Traxboard& tb2) const
{
return (tb1.getHash()<tb2.getHash());
}
};
tr1 unordered containers want an equal to comparision not a less than
one. This is one problem. further it is the objects themselves that
are compared for equality not the hashes. that is internally in
unorderd_* when objects have the same hash they are compared for
equality. The container already knoes that if the hashes are different
the objects are also.
note your functor when actually called will always return false.
You need an equal compare for,which you have so the default
std::equal_to should work.
And the psychic compiler knows that these functions do the wrong thing,
which is why it gave that long, obscure error message!
Seriously: these may well be mistakes in the logic of the functions, but
they won't prevent the code from compiling.
--
-- Pete
Roundhouse Consulting, Ltd. (www.versatilecoding.com)
Author of "The Standard C++ Library Extensions: a Tutorial and
Reference." (www.petebecker.com/tr1book)
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]