Re: std::tr1::unordered_set problem in GCC 4.1.2
In article <hNWdnSoVZfLfoYTbnZ2dnUVZ_vKunZ2d@giganews.com>,
Pete Becker <pete@versatilecoding.com> wrote:
Howard Hinnant wrote:
Your class actually looks like:
class Traxboard {
public:
Traxboard();
bool operator==(const Traxboard& another) const;
bool operator&();
int getHash() const;
};
The gcc code is taking the address of a Traxboard and you're returning a
bool. gcc wants a Traxboard* when it says &(some expression yielding an
lvalue Traxboard).
Which is, nevertheless, a gcc bug, since the key type for an unordered
container is allowed to overloaed operator&. Of course, that's not a
good idea, and should probably not be allowed. It wreaks havoc unless
library code that needs an address carefully works around it.
I believe I disagree with you on both points:
1. The current standard requires &t to yield the address of t.
2. This requirement is unnecessary and should be removed for C++0X.
Containers should use allocator::address(t), and that should work along
the lines of boost::address_of.
References:
20.1.3 [lib.copyconstructible] in C++03 ([copyconstructible]) in N2134.
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2005/n1856.html#20.1.4
%20-%20Copy%20construction
-Howard
--
[ See http://www.gotw.ca/resources/clcm.htm for info about ]
[ comp.lang.c++.moderated. First time posters: Do this! ]