Hi,
I am trying to use the "partition" from STL algorithms. I get the following error:
error: no matching function for call to ‘partition(__gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, <unresolved overloaded function type>)’
/usr/include/c++/4.2.1/bits/stl_algo.h:2098: note: candidates are: _ForwardIterator std::partition(_ForwardIterator, _ForwardIterator, _Predicate) [with _ForwardIterator = __gnu_cxx::__normal_iterator<int*, std::vector<int, std::allocator<int> > >, _Predicate = bool (test::*)(int)]
I am attaching part of my code where I have used partition. I have included the following three libraries:
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
bool test::mypred(int i)
{
if(flag_equiv[i] == 1)
return true;
else
return false;
}
void test::function1
{
for(int i=0; i<(int)temp_myvec1_col.size(); i++)
{
if(temp_myvec1_col[i].size() > 1)
{
counter_temp_equiv = 0;
flag_equiv[0] = 0;
for(int lk=1; lk<(int)temp_myvec1_col[i].size(); lk++)
{
flag_equiv[lk] = 0;
std::map<int,int>::iterator fbg=equiv_pair.find(temp_myvec1_col[i][lk]);
if(fbg != equiv_pair.end())
{
flag_equiv[lk] = 0;
}
else
{
flag_equiv[lk] = 1;
}
}
bound = partition(temp_myvec1_col[i].begin(), temp_myvec1_col[i].end(), mypred);
if(bound != temp_myvec1_col[i].end() && bound != temp_myvec1_col[i].begin())
counter_temp_equiv++;
if(counter_temp_equiv > 0)
{
for(it_equiv=temp_myvec1_col[i].begin(); it_equiv!=bound; ++it_equiv)
{
temp_equiv_vec_row.push_back(*it_equiv);
}
temp_equiv_vec_col.push_back(temp_equiv_vec_row);
temp_equiv_vec_row.clear();
for(it_equiv=bound; it_equiv!=temp_myvec1_col[i].end(); ++it_equiv)
{
temp_equiv_vec_row.push_back(*it_equiv);
}
temp_equiv_vec_col.push_back(temp_equiv_vec_row);
temp_equiv_vec_row.clear();
}
}
}
}
Thanks