]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/example/factorial.cpp
1 /*=============================================================================
2 Copyright (c) 2001-2003 Joel de Guzman
4 Distributed under the Boost Software License, Version 1.0. (See accompanying
5 file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
6 ==============================================================================*/
10 #include <boost/phoenix/core.hpp>
11 #include <boost/phoenix/function.hpp>
15 template <typename Sig
>
18 template <typename This
, typename Arg
>
19 struct result
<This(Arg
)>
20 : result
<This(Arg
const &)>
23 template <typename This
, typename Arg
>
24 struct result
<This(Arg
&)>
29 template <typename Arg
>
30 Arg
operator()(Arg n
) const
32 return (n
<= 0) ? 1 : n
* this->operator()(n
-1);
40 using boost::phoenix::arg_names::arg1
;
41 boost::phoenix::function
<factorial_impl
> factorial
;
43 std::cout
<< factorial(i
)() << std::endl
;
44 std::cout
<< factorial(arg1
)(i
) << std::endl
;