ph::lambda
is the wrong tool for this job (ph::lambda
is a tool for creating nested lambda expressions inside a phoenix expression). Phoenix expressions are already functions, so all that you need to do is find a way to call functions using phoenix expressions (bind), find a way to execute multiple operations in sequence (operator,), and find a way to introduce local variables (let). Putting this all together gives:
#include <cstdint>
#include <iostream>
#include <boost/phoenix.hpp>
namespace ph = boost::phoenix;
using ph::local_names::_a;
using ph::placeholders::arg1;
#define FOO(name) void name( uint32_t val ) {\
std::cout << "\t" << __func__ << "( " << val << " ) called...\n";\
}
FOO(foo)
FOO(bar)
FOO(baz)
int main()
{
auto&& myLambda = ph::let(_a = arg1)
[
ph::bind(foo, _a),
ph::bind(bar, _a),
ph::bind(baz, _a)
];
myLambda(342);
return 0;
}