• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 ////////////////////////////////////////////////////////////////////////////
2 // lazy_argument_tests.cpp
3 //
4 // lazy argument tests passing lazy function as argument.
5 //
6 ////////////////////////////////////////////////////////////////////////////
7 /*=============================================================================
8     Copyright (c) 2001-2007 Joel de Guzman
9     Copyright (c) 2015 John Fletcher
10 
11     Distributed under the Boost Software License, Version 1.0. (See accompanying
12     file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
13 ==============================================================================*/
14 
15 #include <boost/phoenix/core/limits.hpp>
16 
17 #include <boost/detail/lightweight_test.hpp>
18 #include <boost/phoenix/core.hpp>
19 #include <boost/phoenix/function.hpp>
20 
21 namespace example {
22       struct G {
23 
24             template <typename Sig>
25             struct result;
26 
27             template <typename This, typename A0>
28             struct result<This(A0)>
29                : boost::remove_reference<A0>
30             {};
31 
32             template <typename T>
operator ()example::G33             T operator()(T t) const { return ++t; }
34 
35       };
36 }
37 
38 typedef boost::phoenix::function<example::G> GG;
39 boost::phoenix::function<example::G> gg;
40 
41 template <typename F,typename T>
h(F f,T const & t)42 T h(F f, T const& t)
43 {
44   return f(t)();
45 }
46 
main()47 int main()
48 {
49   BOOST_TEST( h(gg,1) == 2);
50   BOOST_TEST(( h<GG,int>(gg,1) == 2));
51 
52   return boost::report_errors();
53 }
54