Boost logo

Boost Users :

Subject: [Boost-users] [Unordered] size() != distance(begin(), end())
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2010-09-13 09:21:36


Dear all,

I have an instance of boost::unordered_map<> somewhere in my codebase (GCC 4.5.1, MinGW, WinXP) with the following funny piece of test code:

container_[id].insert(v);
cout << "container insertion succesful" << endl;
cout << "The container now contains " << container_.size() << " ids in it." << endl;
cout << "distance from begin to end = " << distance(container_.begin(), container_.end()) << endl;

Strangely enough, it happens sometimes that the output I get is:

container insertion succesful
The container now contains 2 ids in it.
distance from begin to end = 1

I.e., size() != distance(begin(), end()) which is against the documentation:

http://www.boost.org/doc/libs/1_44_0/doc/html/boost/unordered_map.html#id1344113-bb

Am I missing anything? Or, is this a bug in the implementation of boost::unordered_map<>?

TIA,
--Hossein


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net