#include <boost/config.hpp>
#include <boost/bind.hpp>
#include <iostream>
#include <vector>
#include <algorithm>
template<class T>
inline T & ToRef( T *pT)
{
return *pT;
}
#define TODEF(x) bind( ToRef<x>, _1)
template<class T>
inline void DeletePointer( T *pT)
{
delete pT;
}
#define ALL(v) (v).begin(), (v).end()
struct X
{
public:
int m_t;
X():m_t(11)
{
}
bool f(int a)
{
std::cout << m_t << std::endl;
return true;
}
};
int main()
{
using namespace boost;
using namespace std;
vector<X *> v;
for( int i=0; i<10; ++i)
v.push_back( new X);
for_each( ALL(v), bind(&X::f, TODEF(X), 4 ) );
for_each( ALL(v), bind( DeletePointer<X>, _1) );
return 0;
}