F
fightwater
i wrote a program which uses the stl compose1 functor
but the compiler seems cannot find it
here is the code
//////////////////////////////////////////
#include <vector>
#include <numeric>
#include <ext/numeric>
#include <algorithm>
#include <ext/algorithm>
#include <functional>
#include <ext/functional>
using namespace std;
int main()
{
int n=10;
vector<int> aa(n);
iota(aa.begin(),aa.end(),2);
copy(aa.begin(),aa.end(),ostream_iterator<int>(cout,"\n"));
vector<int>::iterator
new_end=remove_if(aa.begin(),aa.end(),compose1(
bind2nd(equal_to<int>(),0),
bind2nd(modulus<int>(),2)));
aa.erase(new_end,aa.end());
copy(aa.begin(),aa.end(),ostream_iterator<int>(cout,"\n"));
return 0;
}
////////////////////////////////////////////////////////
above is the code
tostrem.cc: In function 'int main()':
tostrem.cc:20: error: 'compose1' was not declared in this scope
above is the compiler information from the command g++ tostream.cc
It's strange, since I went to the file /ext/functional , it does have
compose1 there?
Does anybody know why?
but the compiler seems cannot find it
here is the code
//////////////////////////////////////////
#include <vector>
#include <numeric>
#include <ext/numeric>
#include <algorithm>
#include <ext/algorithm>
#include <functional>
#include <ext/functional>
using namespace std;
int main()
{
int n=10;
vector<int> aa(n);
iota(aa.begin(),aa.end(),2);
copy(aa.begin(),aa.end(),ostream_iterator<int>(cout,"\n"));
vector<int>::iterator
new_end=remove_if(aa.begin(),aa.end(),compose1(
bind2nd(equal_to<int>(),0),
bind2nd(modulus<int>(),2)));
aa.erase(new_end,aa.end());
copy(aa.begin(),aa.end(),ostream_iterator<int>(cout,"\n"));
return 0;
}
////////////////////////////////////////////////////////
above is the code
tostrem.cc: In function 'int main()':
tostrem.cc:20: error: 'compose1' was not declared in this scope
above is the compiler information from the command g++ tostream.cc
It's strange, since I went to the file /ext/functional , it does have
compose1 there?
Does anybody know why?