相关疑难解决方法(0)

需要帮助BOOST_FOREACH /编译器错误

我知道boost或编译器应该是最后的责任,但我在这里看不到另一种解释.我正在使用msvc 2008 SP1并提升1.43.

在下面的代码片段中,执行永远不会离开第三个 BOOST_FOREACH循环

typedef Graph<unsigned, unsigned>::VertexIterator Iter;

Graph<unsigned, unsigned> g;
g.createVertex(0x66);

// works fine
Iter it = g.getVertices().first, end = g.getVertices().second;
for(; it != end; ++it)
    ;

// fine
std::pair<Iter, Iter> p = g.getVertices();
BOOST_FOREACH(unsigned handle, p)
    ;

// fine
unsigned vertex_count = 0;
BOOST_FOREACH(unsigned handle, g.getVertices())
    vertex_count++;

// oops, infinite loop
vertex_count = 0;
BOOST_FOREACH(unsigned handle, g.getVertices()) 
    vertex_count++;

vertex_count = 0;
BOOST_FOREACH(unsigned handle, g.getVertices())
    vertex_count++;

// ... last block repeated 6 times
Run Code Online (Sandbox Code Playgroud)

迭代器代码:

class Iterator 
    : …
Run Code Online (Sandbox Code Playgroud)

c++ boost visual-c++ boost-foreach

14
推荐指数
1
解决办法
1211
查看次数

标签 统计

boost ×1

boost-foreach ×1

c++ ×1

visual-c++ ×1