// Copyright (C) 2009-2012 Lorenzo Caminiti // Distributed under the Boost Software License, Version 1.0 // (see accompanying file LICENSE_1_0.txt or a copy at // http://www.boost.org/LICENSE_1_0.txt) // Home at http://www.boost.org/libs/local_function #include #include #include //[phoenix_factorial struct factorial_impl { // Phoenix function from global functor. template struct result; template struct result : result {}; template struct result { typedef Arg type; }; template // Polymorphic. Arg operator()(Arg n) const { return (n <= 0) ? 1 : n * (*this)(n - 1); } }; int main(void) { using boost::phoenix::arg_names::arg1; boost::phoenix::function factorial; int i = 4; BOOST_TEST(factorial(i)() == 24); // Call. BOOST_TEST(factorial(arg1)(i) == 24); // Lazy call. return boost::report_errors(); } //]