
Hi there, I need an advanced container which allows me to access my data over number of different indices. That is exactly what for boost::multi_index_container was made. But, my data items also have relationships with other data in the same container, which could be represented as directed graph. So, I have made a custom container, which aggregates multi_index_container (MIC) to store data items and a graph (BGL) to store relationships. To allow switching from MIC to walk over relationships, as an additional field of my item in MIC I store BGL vertex; as vertex property in graph I store the key of unique index in MIC. So, MIC and BGL refer to each other. But, it is difficult to have those two containers in sync. So, I made another attempt to have MIC as customized vertex storage. I succeed two write the code for it (see it below). It also compiles and links :-). Unfortunately, I can not add neither vertices not edges. If I try to add vertex as in commeted code below, an error errors that there is no convertion from vertex property to vertex descriptor (error message is below). What's wrong? My another question is: how can I get access to my MIC stored in graph? I would like to use its indices. Best wishes, Alexander --------- sample code ----------- #include <iostream> #include <boost/multi_index_container.hpp> #include <boost/multi_index/ordered_index.hpp> #include <boost/graph/adjacency_list.hpp> using namespace boost; using namespace boost::multi_index; using namespace std; struct MICSelector {}; struct Item { Item(int _a=0, int _b=0, int _c=0) : a(_a), b(_b), c(_c) {} int a,b,c; }; struct ItemHolder { ItemHolder(int id=0, const Item item=Item()) : m_ID(id), m_item(item) {} int m_ID; Item m_item; }; struct ItemHolderKey { typedef int result_type; int operator()(const ItemHolder& v) const { return v.m_ID; } }; template<class ValueType> struct MICWrapper { typedef multi_index_container < ValueType, indexed_by < ordered_unique< ItemHolderKey > > > type; }; namespace boost { // the specialization for your selector template<class ValueType> struct container_gen<MICSelector, ValueType> { typedef typename MICWrapper<ValueType>::type type; }; template <> struct parallel_edge_traits<MICSelector> { typedef allow_parallel_edge_tag type; }; }; typedef adjacency_list < listS, MICSelector, bidirectionalS, ItemHolder > MG; int tmain(int argc, char* argv[]) { MG mg; /* ItemHolder IH( 1, Item(1) ); add_vertex( &IH, mg ); // add_edge( // ItemHolder( 1, Item(1) ), // ItemHolder( 2, Item(2) ), // mg ); */ cout << typeid( boost::graph_traits<MG>::vertex_descriptor ).name(); return 0; } --------- sample code ----------- ----------- error message ------------- Compiling... MIC_BGL.cpp c:\test\MIC_BGL.cpp(87) : error C2664: 'boost::add_vertex' : cannot convert parameter 1 from 'ItemHolder *__w64 ' to 'const boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config::vertex_property_type &' with [ Graph=boost::adjacency_list<boost::listS,MICSelector,boost::bidirectionalS,ItemHolder>, VertexListS=MICSelector, OutEdgeListS=boost::listS, DirectedS=boost::bidirectionalS, VertexProperty=boost::detail::retag_property_list<boost::vertex_bundle_t,ItemHolder>::type, EdgeProperty=boost::detail::retag_property_list<boost::edge_bundle_t,boost::no_property>::type, GraphProperty=boost::no_property, EdgeListS=boost::listS ] Reason: cannot convert from 'ItemHolder *__w64 ' to 'const boost::detail::adj_list_gen<Graph,VertexListS,OutEdgeListS,DirectedS,VertexProperty,EdgeProperty,GraphProperty,EdgeListS>::config::vertex_property_type' with [ Graph=boost::adjacency_list<boost::listS,MICSelector,boost::bidirectionalS,ItemHolder>, VertexListS=MICSelector, OutEdgeListS=boost::listS, DirectedS=boost::bidirectionalS, VertexProperty=boost::detail::retag_property_list<boost::vertex_bundle_t,ItemHolder>::type, EdgeProperty=boost::detail::retag_property_list<boost::edge_bundle_t,boost::no_property>::type, GraphProperty=boost::no_property, EdgeListS=boost::listS ] No constructor could take the source type, or constructor overload resolution was ambiguous ----------- error message ------------- __________________________________ Do you Yahoo!? Yahoo! Mail - Find what you need with new enhanced search. http://info.mail.yahoo.com/mail_250