mem-fun

How do I use std::tr1::mem_fun in Visual Studio 2008 SP1?

The VS2008 SP1 documentation talks about std::tr1::mem_fun. So why, when I try and use std::tr1::mem_fun, why do I get this compile error?: 'mem_fun' : is not a member of 'std::tr1' At the same time, I can use std::tr1::function without problems. Here is the sample code I am trying to compile, which is supposed to call TakesInt on a...

C# equivalent of C++ mem_fun?

I'd like to do something like the following in C#: class Container { //... public void ForEach(Action method) { foreach (MyClass myObj in sequence) myObj.method(); } } //... containerObj.ForEach(MyClass.Method); In C++ I would use something like std::mem_fun. How would I do it in C...

mem_fun and bind1st problem

I've following class: class A { public: // ctr and etc ... A* clone(B* container); }; Now, I've a vector<A*> availableObjs populated already. I want to call clone on each of those, so and insert cloned objects into a new container clonedObjs of type vector<A*>. I'm trying following - but it doesn't compile: transform(availableObjs....

How to have memfun with two parameters

Hi, I want to use this function "EnumWindows(EnumWindowsProc, NULL);". The EnumWindowsProc is a Callback function: BOOL CALLBACK EnumWindowsProc(HWND hwnd, LPARAM lParam); For this callback I want to use a member function of a class. e.g: Class MyClass { BOOL CALLBACK My_EnumWindowsProc(HWND hwnd, LPARAM lParam); void ...

referencing a member function with bind1st and mem_fun

I have a C++ class where I'm trying to use std::bind1st to bind a member function to the 'this' parameter. For example: class MyClass { public: void Foo() { using namespace std; // this works fine this->Bar(); // this also works fine mem_fun( &MyClass::Bar )( this ); // this does not ...

Using std::vector<T*>::push_back with std::mem_fun and std::bind1st

I'm trying to use std::vector<T*>::push_back with std::mem_fun and std::binder1st, but it doesnt seem to be feasible, can this be done? I've tried to exemplify with the code below. #include <vector> #include <functional> #include <iostream> using namespace std; struct A { int _Foo; virtual int AFoo() { return _Foo; }...

storing mem_fun in a standard container

Is there a way to create a vector< mem_fun_t< ReturnType, MyClass > > ? The error i'm seeing is: error C2512: 'std::mem_fun1_t<_Result,_Ty,_Arg>' : no appropriate default constructor available ...

C++ To call member function in for_each for items in the member container.

If I have a class (that mimic some of STL's container) like this: class Elem { public: void prepare(); // do something on *this // ... }; class Selector { public: typedef vector<Elem *> container_type; typedef container_type::iterator iterator; iterator begin() { return cont_.begin(); } iterator end() { return cont_.end(...