Opened 22 years ago

Closed 22 years ago

#914 closed Bugs (None)

problem with lvalue property maps

Reported by: nobody Owned by: jsiek
Milestone: Component: graph
Version: None Severity:
Keywords: Cc:

Description

[Boost 1.21.1 with egcs 2.95.2]

The code at the end of this report gives me the
compiler error
/usr/local/include/boost/graph/detail/adjacency_list.hpp:
In method `double &
boost::vec_adj_list_vertex_property_map<boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS,boost::property<vertex_info_t,double,boost::no_property>,boost::no_property,boost::no_property>,const
boost::adjacency_list<boost::vecS,boost::vecS,boost::bidirectionalS,boost::property<vertex_info_t,double,boost::no_property>,boost::no_property,boost::no_property>
&,boost::property<vertex_info_t,double,boost::no_property>,vertex_info_t>::operator
[](unsigned int)':
foo.cc:19:   instantiated from here
/usr/local/include/boost/graph/detail/adjacency_list.hpp:2084:
conversion from `const double' to `double &' discards
qualifiers

Apparently operator[] leaves out the const in its
return type for the const_type version of a property
map.

------------- code begins --------------

#include <boost/graph/properties.hpp>
#include <boost/graph/adjacency_list.hpp>

using namespace boost;

struct vertex_info_t { };
namespace boost {
  BOOST_INSTALL_PROPERTY(vertex, info);
};

typedef property<vertex_info_t, double>
vertex_properties;

typedef adjacency_list<vecS, vecS, bidirectionalS,
vertex_properties> graph_t;

double const & foo(graph_t const & x)
{
  property_map<graph_t, vertex_info_t>::const_type pmap
    = get(vertex_info_t(), x);
  return pmap[vertex(0, x)];
}

Change History (1)

comment:1 by jsiek, 22 years ago

Status: assignedclosed
Logged In: YES 
user_id=32836

Yes, this is a bug. I've fixed it and checked the changes
into CVS.
Also added the above file into the test suite.
Note: See TracTickets for help on using tickets.