
On Sat, Nov 26, 2011 at 7:28 AM, Lorenzo Caminiti <lorcaminiti@gmail.com> wrote:
On Thu, Nov 24, 2011 at 1:14 PM, Thomas Heller <thom.heller@googlemail.com> wrote:
Here is what I have to propose: Why not combine Boost.Local and Boost.Phoenix and keep everybody happy?
Hello Thomas, Joel, Hartmut, et alt. Sorry for asking again... I know we are all trying to get disintoxicated from the last week's discussions :)
int main() { using boost::phoenix::arg_names::arg1;
std::vector<int> v(3); v[0] = 1; v[1] = 2; v[2] = 3; int offset = 10;
// Phoenix function defined locally: int BOOST_LOCAL_FUNCTION_PARAMS(int x, bind offset) { int total = x + offset; std::cout << total << std::endl; return total; } BOOST_LOCAL_FUNCTION_NAME(local_add)
boost::phoenix::function<BOOST_LOCAL_TYPEOF(local_add)> pl_add = local_add; std::for_each(v.begin(), v.end(), pl_add(arg1));
return 0; }
Would this ability to plug local functions into Phoenix be useful?
// some global scope template<typename Arg1> Arg1 BOOST_PHOENIX_FUNCTION_TPL(Arg1 const& n) { return (n <= 0) ? 1 : n * (*this)(n - 1); } BOOST_PHOENIX_FUNCTION_END(factorial_impl);
boost::phoenix::function<factorial_impl> f;
Is there any interest in the above macros to define Phoenix functions at global scope? Thanks a lot. --Lorenzo