This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

What is a==b supposed to do for two hash_sets?


Hi,

I was reading through the code of hash_set, when I spotted something
which looks really odd to me: Comparison of two hash_sets is done by
comparing the buckets one by one. To give the simplest possible example,
doing

	#include <iostream>
	#include <ext/hash_set>

	int main(void)
	{
		__gnu_cxx::hash_set<int> x(1000), y;
		std::cout << "x empty ? " << x.empty() << '\n';
		std::cout << "y empty ? " << y.empty() << '\n';
		std::cout << "x == y  ? " << (x == y) << '\n';

		return 0;
	}

gives the output:

	x empty ? 1
	y empty ? 1
	x == y  ? 0

I think this is wrong: My feeling is that two hash_sets should be
considered equal iff they contain the same elements. I can't find any
statement saying so though, neither in SGI's documentation nor
elsewhere.

Is this a bug? Should I file a PR?

--Lorenz


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]