|
Boost : |
From: Ed Brey (brey_at_[hidden])
Date: 2003-07-01 13:16:44
Arkadiy Vertleyb wrote:
> If I understand correctly, with your approach:
>
> (a, b, null) == (a, b, c1), and
> (a, b, null) == (a, b, c2), but
> (a, b, c1) != (a, b, c2)
>
> If this is correct, I am afraid that whether or not such a predicate
> works correctly may depend on a particular implementation of
> std::set...?
It shouldn't. Once you define the strict weak ordering, set's behavior is well defined. The compare function would look like this:
// Returns true iff first element is less than second.
struct Compare {
bool operator()(Key const& t1, Key const& t2) {
for n = 1 to number of fields:
if nth field in t1 == null or nth field in t2 == null:
return false
if nth field in t1 < nth field in t2:
return true
return false
}
};
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk