using graph_property_iter_range::const_iterator

I'm using boost 1_31_0 and gcc 3.4.2. I'm adding an iterator interface to my class that abstracts use of internal boost graph properties and have had success with one exception that involves const_iterator. Here is how this class looks: struct VertexData { typedef boost::graph_property_iter_range <DataGraphT,vertex_Datum_t>::iterator iterator; typedef boost::graph_property_iter_range <DataGraphT,vertex_Datum_t>::const_iterator const_iterator; typedef Vertex_Datum value_type; VertexData(DataGraphT& dataGraph); iterator begin(void) {return boost::get_property_iter_range(dataGraph_,vertex_Datum).first;} // const_iterator begin(void) const {return boost::get_property_iter_range(dataGraph_,vertex_Datum).first;} iterator end(void) {return boost::get_property_iter_range(dataGraph_,vertex_Datum).second;} // const_iterator end(void) const {return boost::get_property_iter_range(dataGraph_,vertex_Datum).second;} When I uncomment the const begin method, I get the following compilation error: dataGraph.h:30: error: conversion from `boost::detail::lvalue_pmap_iter<boost::counting_iterator<size_t, boost::use_default, boost::use_default>, boost::subgraph_global_property_map<DataGraphT*, boost::vec_adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_index_t, int, VertexProperty>, EdgeProperty, boost::no_property, boost::listS>, boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_index_t, int, VertexProperty>, EdgeProperty, boost::no_property, boost::listS>*, Vertex_Datum, Vertex_Datum&, vertex_Datum_t> > >' to non-scalar type `boost::detail::lvalue_pmap_iter<boost::counting_iterator<size_t, boost::use_default, boost::use_default>, boost::subgraph_global_property_map<const DataGraphT*, boost::vec_adj_list_vertex_property_map<boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_index_t, int, VertexProperty>, EdgeProperty, boost::no_property, boost::listS>, const boost::adjacency_list<boost::vecS, boost::vecS, boost::bidirectionalS, boost::property<boost::vertex_index_t, int, VertexProperty>, EdgeProperty, boost::no_property, boost::listS>*, Vertex_Datum, const Vertex_Datum&, vertex_Datum_t> > >' requested Could somebody point out the problem here?

On Sep 20, 2004, at 12:27 PM, Jeffrey Holle wrote:
const_iterator begin(void) const {return boost::get_property_iter_range(dataGraph_,vertex_Datum).first;}
Is dataGraph_ stored as a reference? You probably want: return boost::get_property_iter_range(static_cast<const DataGraph&>(dataGraph_),vertex_Datum).first; Doug

Thanks for this! It works perfectly,const_cast works too. Doug Gregor wrote:
On Sep 20, 2004, at 12:27 PM, Jeffrey Holle wrote:
const_iterator begin(void) const {return boost::get_property_iter_range(dataGraph_,vertex_Datum).first;}
Is dataGraph_ stored as a reference? You probably want:
return boost::get_property_iter_range(static_cast<const DataGraph&>(dataGraph_),vertex_Datum).first;
Doug
participants (2)
-
Doug Gregor
-
Jeffrey Holle