[multiindex] - lower_bound/upper_bound return wrong results
Hello,
The example below should print out only the items {1.0, true} and {2.0,
true} but not {1.5, false}.
What is going wrong?
Regards,
Oliver
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <stdexcept>
#include <utility>
#include
Oliver.Kowalke@qimonda.com wrote:
Hello, The example below should print out only the items {1.0, true} and {2.0, true} but not {1.5, false}. What is going wrong?
The result is correct. Composite keys do comparison from left to right: only when the weight is equal is the assignability even considered for sorting. Thus, {1.5, false} sorts between {1.0, true} and {2.0, true} and thus is part of your range. Switch the order in your composite key and you'll get the results you expect: mi::composite_key< item, mi::const_mem_fun< item, bool, &item::asignable >, mi::const_mem_fun< item, double, & item::weight > > Sebastian Redl
participants (2)
-
Oliver.Kowalke@qimonda.com
-
Sebastian Redl