This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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 



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]