Modifying bundled properties from visitor

孤人 提交于 2019-12-03 15:51:47
baol

Your solution is right.

To decouple the graph type from the visitor you could pass only the interesting property map to the visitor constructor and access its elements using boost::get(property, u) = s3d::cV::leaf;. This way you can pass any type-compatible vertex property to the visitor (the visitor will be more general and not sensible to name changes in the graph type).

The type for the property map will be a template type-name for the visitor class and will be something like:

typedef property_map<graph_t, s3d_cv3_leaf_t your_vertex_info::*>::type your_property_map;

See here for a complete dissertation about bundled properties.

HTH

I'm just learning this stuff, but I think it is correct that you must store a reference to the graph in the visitor. I'm not sure if it's for this reason, but it may be because they didn't want to provide two versions of all of the functions/require derivatives to provide two versions of each function. Especially when the pass in the graph workaround is available.

Even if it feels weird, I think passing in a reference to the graph may be the "right way".

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!