我想用纯C++ 11等价物替换顶点或边上的BGL迭代。 BGL的代码(来自:http://www.boost.org/doc/libs/1_52_0/libs/graph/doc/quick_tour.html)是:用“纯”C++ 11替代替换BGL迭代顶点?
typename boost::graph_traits<Graph>::out_edge_iterator out_i, out_end;
typename boost::graph_traits<Graph>::edge_descriptor e;
for (std::tie(out_i, out_end) = out_edges(v, g);
out_i != out_end; ++out_i)
{
e = *out_i;
Vertex src = source(e, g), targ = target(e, g);
std::cout << "(" << name[get(vertex_id, src)]
<< "," << name[get(vertex_id, targ)] << ") ";
}
我试了几个建议从这里开始:Replace BOOST_FOREACH with "pure" C++11 alternative?但没有运气。
我希望能够写类似:
for (auto &e : out_edges(v, g))
{ ... }
或类似的东西:
for (std::tie(auto out_i, auto out_end) = out_edges(v, g);
out_i != out_end; ++out_i)
{...}
这可能吗?
谢谢,但您提供的代码甚至没有编译:(请看看源代码(包括您的代码):http://pastebin.com/Nx7WeMhU –
@ danilo2:究竟是什么错误? – Xeo
在这里他们是:http://pastebin.com/LDLRYwNG(另外我添加';'第20行,因为没有它缺少分号语法错误) –