Boost logo

Boost Users :

Subject: [Boost-users] Boost Graph: why can't get() take a const argument?
From: Trevor Harmon (Trevor.W.Harmon_at_[hidden])
Date: 2010-05-03 19:33:35


Hi,

I have a question about line 54 of the canonical_ordering example:

   graph g(6);
   ...
   property_map<graph, edge_index_t>::type e_index = get(edge_index, g);

If I'm reading the Boost source code correctly, the get function's
graph argument is declared const. This makes sense intuitively
because, well, why would the graph need to be modified in order to
retrieve a property? So the graph parameter passed to get() could be
made const, correct? Like this:

   graph g(6);
   ...
   const graph g2 = g;
   property_map<graph, edge_index_t>::type e_index = get(edge_index,
g2);

However, the above change gives a compiler error:

conversion from
‘boost::adj_list_edge_property_map<boost::undirected_tag, int, const
int&, size_t, const boost::property<boost::edge_index_t, int,
boost::no_property>, boost::edge_index_t>’ to non-scalar type
‘boost::adj_list_edge_property_map<boost::undirected_tag, int, int&,
size_t, boost::property<boost::edge_index_t, int, boost::no_property>,
boost::edge_index_t>’ requested

Can anyone explain why? Thank you,

Trevor


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