Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#3529 closed Bugs (invalid)

boost::interprocess::map can't find() elements which exist in the map

Reported by: anonymous Owned by:
Milestone: Boost 1.41.0 Component: interprocess
Version: Boost 1.40.0 Severity: Problem
Keywords: Cc:

Description

I have prepared a relatively small C++ program to demonstrate the problem: I create an empty segment and a map within, put there few elements and then try to list the whole map and to find specific items. Some items are perfectly visible when iterting over the map, but can't be found via find().

If I put some traces into operator< (), I can see that only few comparsions are made (less then expected) when searching for a "missing" key

Attachments (2)

testmap.cc (3.8 KB ) - added by morozov@… 13 years ago.
the test C++ program
execution_results (1.7 KB ) - added by morozov@… 13 years ago.
Execution results

Download all attachments as: .zip

Change History (4)

by morozov@…, 13 years ago

Attachment: testmap.cc added

the test C++ program

by morozov@…, 13 years ago

Attachment: execution_results added

Execution results

comment:1 by Steven Watanabe, 13 years ago

Resolution: invalid
Status: newclosed

Your comparison operator is not quite right. It should be

bool operator<(const RouteKey& _o) const {
    return (this->tv_sec < _o.tv_sec ||
            (this->tv_sec == _o.tv_sec && (this->tv_usec < _o.tv_usec ||
            (this->tv_usec == _o.tv_usec && this->pid < _o.pid))
            ));
}

(warning untested)

comment:2 by Steven Watanabe, 13 years ago

Component: Noneinterprocess
Note: See TracTickets for help on using tickets.