I'm a little confused on the correct way to lazily call a boost::function
in a phoenix expression. For example, this doesn't do anything:
namespace bp = boost::phoenix;
namespace bpa = bp::arg_names;
struct Foo
{
boost::function< void() > callback;
Foo(boost::function< void() > const& callback) :
callback(callback)
{
}
};
main()
{
std::list< Foo > foos;
foos.push_back(Foo(std::cout << bp::val(1) << '\n'));
foos.push_back(Foo(std::cout << bp::val(2) << '\n'));
foos.push_back(Foo(std::cout << bp::val(3) << '\n'));
std::for_each(
foos.begin(),
foos.end(),
bp::bind(&Foo::callback, bpa::arg1));
}
If I wrap the bind(...) in another bind(...) it'll work, but is that the
right way? I'm not binding anything, I just want the callback called.