Reputation: 1005
So I have this vector:
vector<boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> > wait;
And I want to search if for the ones that have true in them, how can I do that, that's it.
Any suggestion I have looked into boost::phoenix but not really sure how it works, any ideas.
Thanks.
Upvotes: 0
Views: 719
Reputation: 52365
Since you are just starting off, here is some example code (I don't what compiler you are using, but you could use auto
, range-based for etc. if you have C++11 support):
typedef vector<boost::tuple<ppa::Node*, ppa::Node*, ppa::Node*, bool> >::iterator vec_iter;
for (vec_iter i = wait.begin(); i != wait.end(); ++i)
{
if (boost::get<3>(*i) == true)
{
// This tuple has true in it, so do something
}
}
C++11 version:
for (auto& i : wait)
{
if (boost::get<3>(i) == true)
{
// Do stuff
}
}
Upvotes: 0
Reputation: 143139
Something like this std::find_if(wait.begin(),wait.end(),istruetuple)
...
Upvotes: 3