boost::variant's and > 10 supported types
Hi, How do I support > 10 types in a variant without having support for make_variant_over (since I wish to still support Borland and MSVC 6/.NET (aka. 7, not 7.1), as well as gcc). To be precise, I need 18 types to be supported. -- PreZ Founder The Neuromancy Society http://www.neuromancy.net
hi list i am developping a scheduling algorithm usig boost graph library. I want to update the list of the ready tasks. for that , i develop a function template <class Vertex,class Graph> file://this tests if all parent of vertex v are scheduled // i.e v is a ready task bool isReady(const Vertex v,const Graph g){ typedef typename property_map<Graph, vertex_first_name_t>::const_type NamePA; NamePA name = get(vertex_first_name, g); typedef typename boost::property_traits<NamePA>::value_type NameType; // typename boost::property_map<Graph, vertex_index_t>::type id = get(vertex_index, g); NameType src_name; boost::graph_traits<Graph>::vertex_iterator vi; for (vi=in_edges(v,g).first; // XXXXXXXX vi!=in_edges(v,g); ++vi){ /// if (name[*vi]==false) return false; } return true; } and I call it from template <class Graph> void allocate1(Graph &g,vector<MACHINE> &m){ typedef typename property_map<Graph, vertex_first_name_t>::type NamePA; NamePA name = get(vertex_first_name, g); typedef typename boost::property_traits<NamePA>::value_type NameType; typename boost::property_map<Graph, vertex_index_t>::type id = get(vertex_index, g); typedef typename boost::graph_traits<Graph>::vertex_descriptor vertex; NameType src_name; boost::graph_traits<Graph>::vertex_iterator vi; typedef list<vertex> vlist; vlist readyTasks; cerr << "Machine number :" << m.size() << endl; ///////////// initialising the ready tasks list for (vi=vertices(g).first;vi!=vertices(g).second;++vi){ if (in_degree(*vi,g)==0) readyTasks.push_back(*vi); cerr << "pushing vertex "<<id[*vi]<<endl; } } /////////// for(vlist::iterator it=readyTasks.begin(); it!=readyTasks.end(); ++it){ name[*it].isScheduled(); file://the task has been scheduled for (vi=vertices(g).first;vi!=vertices(g).second;++vi){ vertex temp=*vi; if (isReady<vertex,Graph>(temp,g)==true) { readyTasks.push_back(*vi); cerr << "pushing vertex "<<id[*vi]<<endl; } } } } but the compiler (g++ 3.X on linux) returns me an error ( saying that it cannot find attribute .. and points me on line XXXXXXX) please, do you see any error in isReady() function. thanks adel
Hi Adel, On Mar 27, 2004, at 9:13 PM, Adel Essafi wrote:
NameType src_name; boost::graph_traits<Graph>::vertex_iterator vi;
for (vi=in_edges(v,g).first; // XXXXXXXX vi!=in_edges(v,g); ++vi){
The return type of in_edges() is a pair of in_edge_iterator's, not vertex_iterator's. So you should do something like this instead: boost::graph_traits<Graph>::in_edge_iterator ei; for (ei=in_edges(v,g).first; ei != in_edges(v.g).second; ++ei){ Hope that helps, Jeremy P.S. Also I recommend using boost::tie in the for loop, as is done in most of the graph examples.
"Preston A. Elder" <prez@neuromancy.net> writes:
Hi,
How do I support > 10 types in a variant without having support for make_variant_over (since I wish to still support Borland and MSVC 6/.NET (aka. 7, not 7.1), as well as gcc).
To be precise, I need 18 types to be supported.
You might look at http://www.boost.org/doc/html/variant.tutorial.html#variant.tutorial.over-se... -- Dave Abrahams Boost Consulting www.boost-consulting.com
Hi Preson, Sorry for the slow reply. (I don't monitor the Boost Users list, and I probably should. Thanks to Dave Abrahams for alerting me to your post.) Preston A. Elder wrote:
How do I support > 10 types in a variant without having support for make_variant_over (since I wish to still support Borland and MSVC 6/.NET (aka. 7, not 7.1), as well as gcc).
To solve your problem under the current implementation, you need a greater value for BOOST_MPL_LIMIT_LIST_SIZE. I'm unfortunately not attuned enough to the MPL implementation to know what is involved in attaining this; I've CCed this to Aleksey Gurtovoy (the MPL maintainer), who may be able to help you. Also, I have some ideas for possibly making make_variant_over work under Borland in a future release. Of course, this doesn't address MSVC6, but I'm guessing that it is a lost cause anyhow. Sorry I couldn't help more. Eric
participants (5)
-
Adel Essafi
-
David Abrahams
-
Eric Friedman
-
Jeremy Siek
-
Preston A. Elder