Opened 12 years ago
Closed 12 years ago
#4544 closed Bugs (fixed)
shared_ptr seems to be mistake in unordered_set
Reported by: | Owned by: | Daniel James | |
---|---|---|---|
Milestone: | Boost 1.47.0 | Component: | hash |
Version: | Boost 1.44.0 | Severity: | Problem |
Keywords: | Cc: |
Description
class Abc { };
int main() {
boost::shared_ptr a(new Abc); boost::shared_ptr b(new Abc); unordered_set<shared_ptr<Abc> > xx; xx.insert(a); xx.insert(b);
always get 1 here, cout << xx.hash_function()(a) << " " << xx.hash_function() << endl;
return 0;
}
judging two objects pointed by shared_ptr should compare the address of them, but how hash_function() always returns 1?
Change History (2)
comment:1 by , 12 years ago
Component: | None → hash |
---|---|
Milestone: | Boost.Jam 4.0.0 → To Be Determined |
Owner: | set to |
Status: | new → assigned |
comment:2 by , 12 years ago
Milestone: | To Be Determined → Boost 1.47.0 |
---|---|
Resolution: | → fixed |
Status: | assigned → closed |
shared_ptr now has support for hash in trunk [69260].
Note:
See TracTickets
for help on using tickets.
Boost.Hash doesn't have support for
shared_ptr
, but there's a bug which causes it to convert them to bools (which is why it's always 1). If you defineBOOST_HASH_NO_IMPLICIT_CASTS
then it will correctly fail to compile. This will probably happen by default in Boost 1.45.