BGL: std::map<Edge, int> needs the < operator
I'm trying to have a std::map where the key is an edge of a graph, but
I get a compilation error. My graph is:
typedef boost::adjacency_list
write your own total ordering/comparison function object for Edge objects and declare the map type using this function. On Apr 20, 2006, at 7:55 PM, Irek Szczesniak wrote:
I'm trying to have a std::map where the key is an edge of a graph, but I get a compilation error. My graph is:
typedef boost::adjacency_list
, property > > Graph; And an edge:
typedef graph_traits<Graph>::edge_descriptor Edge;
Then I have a map:
std::map
m; But when I try this:
m[e] = 0
where e is of type Edge, then I get:
/usr/lib/gcc/i386-redhat-linux/3.4.4/../../../../include/c++/3.4.4/ bits/stl_function.h:227: error: no match for 'operator<' in '__x < __y'
Can I use map with the Edge as the key type? If so, what should I do?
Thanks for reading.
Best, Irek _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
I'm using the following for a couple of monthes. Seems to work.
//////////////////////////////////////////
struct edge_less_than
: public std::binary_function
write your own total ordering/comparison function object for Edge objects and declare the map type using this function.
On Apr 20, 2006, at 7:55 PM, Irek Szczesniak wrote:
Yes, I also recommend the function object approach. You won't have to worry about which namespace the function object is in... this avoids the argument dependent lookup issues that caused problems for the global operator<. Cheers, Jeremy On Apr 20, 2006, at 10:26 PM, Thomas Costa wrote:
write your own total ordering/comparison function object for Edge objects and declare the map type using this function.
Hi,
Thank you all for responding to my post. Now I have my own operator
function object for the comparison as you advised:
struct cmp_edge :
public std::binary_function
Yes, I also recommend the function object approach. You won't have to worry about which namespace the function object is in... this avoids the argument dependent lookup issues that caused problems for the global operator<.
Cheers, Jeremy
On Apr 20, 2006, at 10:26 PM, Thomas Costa wrote:
write your own total ordering/comparison function object for Edge objects and declare the map type using this function.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (4)
-
Dmitry Bufistov
-
Irek Szczesniak
-
Jeremy Siek
-
Thomas Costa