mem_fun family (for_each, bind..)

Levente Farkas !spam-lfarkas@mindmaker.hu
Fri Aug 6 04:51:00 GMT 1999


hi,
it's another strange program :
-----------
#include <vector>
#include <functional>
#include <algorithm>

class A
{
  typedef std::vector<A *> vec;
  vec v;
public:
  void f(double& d) const { ++d; }
  void g()
  {
    double d = 1;
    std::for_each(v.begin(), v.end(), 
                  std::bind2nd(std::mem_fun(&A::f), d));
  }
};

int main()
{
  A a;
  a.g();
  return 0;
}
-----------
I'm just wondering "is there anybody who realy try to use standard c++ ?".
since I run into problems like this day after day. I'm not talking about 
that microsoft standard implemetation sucks all the day (like in the above
ms forget to implement const member function (it can be corrected in
ms's header file), but can't corrent template specialization for void since
ms's compiler don't support it), but this simple example can't compile even
on the latest egcs/gcc - 2.95!
or am I wrong ?

 -- Levente


More information about the Gcc mailing list