Opened 12 years ago

Closed 12 years ago

#4544 closed Bugs (fixed)

shared_ptr seems to be mistake in unordered_set

Reported by: showern <showern@…> 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 Daniel James, 12 years ago

Component: Nonehash
Milestone: Boost.Jam 4.0.0To Be Determined
Owner: set to Daniel James
Status: newassigned

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 define BOOST_HASH_NO_IMPLICIT_CASTS then it will correctly fail to compile. This will probably happen by default in Boost 1.45.

comment:2 by Daniel James, 12 years ago

Milestone: To Be DeterminedBoost 1.47.0
Resolution: fixed
Status: assignedclosed

shared_ptr now has support for hash in trunk [69260].

Note: See TracTickets for help on using tickets.