binder2nd

P

PS

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;
}
 
I

Ian

PS said:
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&).
You have to compile with -library=stlport4, the original Sun STL does
not support template member functions.

Ian
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,919
Messages
2,570,037
Members
46,444
Latest member
MadeleineH

Latest Threads

Top