|
Boost Users : |
From: Dmitry Bufistov (dmitry_at_[hidden])
Date: 2006-04-21 08:13:24
Ovanes,
In your implementation you need to change edge_descriptor class. Is it
possible to do the same without such modification? I was trying define
such global operator
bool operator<(const edge_descriptor_t& __x, const edge_descriptor_t&__y)
{
return __x.get_property() < __y.get_property();
}
but it doesn't work for me (when I try to instantinate some std::map
for edge I have compilation error:
1>C:\Program Files\Microsoft Visual Studio 8\VC\include\functional(143)
: error C2678: binary '<' : no operator found which takes a left-hand
operand of type 'const edge_descriptor_t' (or there is no acceptable
conversion)
Thank you,
--dmitry
Ovanes Markarian wrote:
>
> Another way would be to implement a global less than operator overload. You can also implement
> this operator within a class, so that std::less_than is able to call it.
>
>
> //implementig the comaprison operator in the class
> // if you don't want this operator to be accessible from other classes,
> // declare the std::less_than<Edge> as friend and make this operator protected
> class Edge
> {
> friend class std::less_than<Edge>;
>
> protected:
> inline bool operator <(const Edge& e)
> {
> return (prop1 < e.prop1) && (prop2 < e.prop2) && ...;
> }
>
> //your class implementation
> };
>
>
> Ovanes Markarian
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