Boost logo

Boost Users :

From: Gat, Yoram (yoram.gat_at_[hidden])
Date: 2005-10-28 13:59:46


Hi all,

 

I just started using BGL and created the following program (MSVS 7.1),
storing some data in an interior property and then retrieving them:

 

#include "boost/graph/adjacency_list.hpp"

 

struct NodeProperties { int a, b, c; };

 

typedef boost::adjacency_list<

      boost::listS,boost::listS,boost::undirectedS,

      boost::property<boost::vertex_all_t,NodeProperties>

> Graph;

 

typedef boost::graph_traits<Graph>::vertex_descriptor VertexDescriptor;

typedef boost::property_map<Graph,boost::vertex_all_t>::type AllMap;

 

int main(int argc, char const *argv[])

{

      Graph graph;

      AllMap allMap = get(boost::vertex_all,graph);

 

      VertexDescriptor vd = boost::add_vertex(graph);

      NodeProperties np;

      np.a = 1; np.b = 2; np.c = 3;

      allMap[vd] = np;

 

      NodeProperties np1 = allMap[vd];

// const AllMap::value_type &vt = boost::get(allMap,vd);

// NodeProperties np1 = vt.m_value;

 

      return 0;

}

 

For which I get the following error:

 

c:\Documents and
Settings\ygat\Desktop\Work\InternalProperty\InternalProperty.cpp(24):
error C2440: 'initializing' : cannot convert from
'boost::detail::vertex_property_map<Graph,PropertyTag>::Property' to
'NodeProperties'

        with

        [

            Graph=Graph,

            PropertyTag=boost::vertex_all_t

        ]

 

After some poking around, I discovered that if I replace the offending
line with the two commented lines, things work. Is this the right way to
retrieve the data? Why can the NodeProperties object be on the rhs but
not on the lhs of an assignment to the property map?

 

Thanks,

Yoram

 

 



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