
On Mar 27, 2012, at 2:13 PM, Robert Jones wrote:
Ultimately I'm doing this for each member of a range, via std algorithm, so I need to bind a unary argument to produce a nullary function object, which I can then pass to an evaluation context, ie my g( ) function. If I've generated the function object with bind and placeholder(s), it seems there's no way to prevent the binding of the last placeholder from triggering evaluation, when what I require is an unevaluated nullary function object.
Hmm, works for me, IIUC: #include <boost/bind.hpp> #include <iostream> template<typename F> void g(F const &f) { f(); } void f(int x) { std::cout << "x is " << x << std::endl; } int main() { for(int i=0; i<7; ++i) g(boost::bind(f,i)); return 0; }