I am using visual studio 2010 and I am trying to use std::copy_if, I want to copy all values that are satisfying a predicate. For example:
struct comp
{
bool operator()(const int i) { return i == 5 || i == 7; }
};
int main()
{
array<int, 10> arr = { 3, 2, 5, 7, 3, 5, 6, 7 };
vector<int> res;
copy_if(arr.begin(), arr.end(), res.begin(), comp());
for(int i = 0; i < res.size(); i++)
{
cout << res[i] << endl;
}
return 0;
}
But when I run this code I get: vector iterator not incrementable.