bool pred(int k, int l, int num1, int num2)
{
return (num1 < num2);
}
int main()
{
vector <int> nums;
for (int i=50; i > 0; --i)
{
nums.push_back(i);
}
std::sort (nums.begin(), nums.end(), boost::bind(&pred, 5, 45));
}
I am a boost newbie. I was learning to use boost::bind and I wanted to sort a vector of integers and get rid of all those elements in the vector that are greater than 45 and less than 5. Had a hard time doing it. Would be great if anyone could help me do it?
The reason I am facing problem is because I am trying to get rid of a vector element while iterating through the vector to sort it. I know it would be much easier if i sort it first and then remove elements from it. But I want to do it this way. Any help is appreciated.