Boost logo

Boost Users :

From: Doug Gregor (dgregor_at_[hidden])
Date: 2004-08-23 13:25:00


On Aug 23, 2004, at 11:30 AM, Jeff Holle wrote:

> I may have answered my own question.
> The Compare functor that does the trick is:
> struct ltExternalEdge : public
> std::binary_function<ExternalEdge,ExternalEdge, bool> {
> bool operator()(const ExternalEdge& __x, const ExternalEdge& __y)
> const
> {
> return (__x.first < __y.first || (!(__y.first < __x.first) &&
> __x.second.get_property() < __y.second.get_property())) ? true :
> false;
> }
> };
>
> Is such a Compare operator safe? Note that I'm note using internal
> properties.

This is not guaranteed to work, because edge descriptors aren't
required to have the "get_property" or "first" members. Practically
speaking, I think it will work, but can't be sure.

> It would be really nice if the object that edge_iterator references
> implemenented a operator< method.
> Then it would work seamlessly with the std::pair operator< method,
> which
> I pretty much copied in the above code.

I'm not sure that this can always be implemented efficiently, but it
surely would be useful.

        Doug


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