This is the mail archive of the
gcc-bugs@gcc.gnu.org
mailing list for the GCC project.
Re: libstdc++/6532: STL binder1st::operator() not compiling
- From: Paolo Carlini <pcarlini at unitus dot it>
- To: gcc-gnats at gcc dot gnu dot org, gcc-prs at gcc dot gnu dot org, olaf dot dietsche at gmx dot net, gcc-bugs at gcc dot gnu dot org
- Date: Thu, 02 May 2002 14:29:44 +0200
- Subject: Re: libstdc++/6532: STL binder1st::operator() not compiling
Hi,
your analysis is essentially correct. This is a limitation of the
standard binders... Boost (www.boost.org) to the rescue! Why don't
consider using boost::bind? Like this:
#include <algorithm>
#include <functional>
#include <boost/bind.hpp>
using namespace std;
using namespace boost;
struct A {
int _a;
};
struct B {
void m(A &x) { x._a = 5; }
void f();
};
void B::f()
{
A a[5];
for_each(&a[0], &a[5], bind(&B::m, ref(this), _1));
}
Ciao,
Paolo.
http://gcc.gnu.org/cgi-bin/gnatsweb.pl?cmd=view%20audit-trail&database=gcc&pr=6532