Connecting Tech Pros Worldwide Forums | Help | Site Map

binder2nd

PS
Guest
 
Posts: n/a
#1: Dec 3 '05
Hi,
I wrote the following code to try using bind2nd.
It compiles and works fine with g++ but a Sun compiler tells me :

"test_bind2nd.cpp", line 21: Error: Cannot cast from
std::binder2nd<std::greater<int>> to bool(*)(const int&).

Could you tell me if there's something wrong with the code itself?
Thanks,
PS
__________________________________________________ _____
#include <iostream>
#include <iomanip>
#include <functional>
#include <list>
#include <iterator>
using namespace std;

class A {
public:
A(int size, int ival) :
l(size, ival)
{};
void FillList() {
l.push_back(4);
l.push_front(2);
return;
}
void CleanList(int i) {
l.remove_if(bind2nd(greater<int>(), i));
return;
}
void PrintList() {
cout << "List: ";
copy(l.begin(), l.end(), ostream_iterator<int>(cout, " "));
cout << endl;
}
private:
list<int> l;
};

int main(int argc, char *argv[]) {

A a(10, 7);

a.PrintList();
a.FillList();
a.PrintList();
a.CleanList(6);
a.PrintList();

return EXIT_SUCCESS;
}

Ian
Guest
 
Posts: n/a
#2: Dec 3 '05

re: binder2nd


PS wrote:[color=blue]
> Hi,
> I wrote the following code to try using bind2nd.
> It compiles and works fine with g++ but a Sun compiler tells me :
>
> "test_bind2nd.cpp", line 21: Error: Cannot cast from
> std::binder2nd<std::greater<int>> to bool(*)(const int&).
>[/color]
You have to compile with -library=stlport4, the original Sun STL does
not support template member functions.

Ian
Closed Thread