开发者

Boost C++ macro argument count error

In the following piece of code:

BOOST_FOREACH(std::pair<PID, bool> &itval, completedEs_) {
    allCompleted &= it->second;
}

I'm getting this error:

error: macro "BOOST_FOR开发者_开发知识库EACH" passed 3 arguments, but takes just 2

I'm only passing 2 arguments, what's going on?


The first type is being parsed as two arguments since it contains a comma. As a workaround you could typedef the type:

typedef std::pair<PID, bool> PID_bool_pair;
BOOST_FOREACH( PID_bool_pair &itval, completedEs_) {
    ...
}


You can't do that because of BOOST_FOREACH macro limitations, rewrite it like:

//...
typedef std::pair<PID, bool> mypair;
BOOST_FOREACH(mypair &itval, completedEs_) {
    allCompleted &= it->second;
}
//...
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜