]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/phoenix/test/function/lazy_templated_struct_tests.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / phoenix / test / function / lazy_templated_struct_tests.cpp
1 ////////////////////////////////////////////////////////////////////////////
2 // lazy_templated_struct_tests.cpp
3 //
4 // lazy templated struct test to check this works everywhere.
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 #include <boost/function.hpp>
21
22 namespace example {
23
24 namespace impl {
25 // Example of templated struct.
26 template <typename Result>
27 struct what {
28
29 typedef Result result_type;
30
31 Result operator()(Result const & r) const
32 {
33 return r;
34 }
35 };
36
37 template <typename Result>
38 struct what0 {
39
40 typedef Result result_type;
41
42 Result operator()() const
43 {
44 return Result(100);
45 }
46
47 };
48
49 }
50
51 boost::function1<int, int > what_int = impl::what<int>();
52 boost::function0<int> what0_int = impl::what0<int>();
53 BOOST_PHOENIX_ADAPT_FUNCTION(int,what,what_int,1)
54 BOOST_PHOENIX_ADAPT_FUNCTION_NULLARY(int,what0,what0_int)
55 }
56
57 int main()
58 {
59 int a = 99;
60 using boost::phoenix::arg_names::arg1;
61 BOOST_TEST(example::what_int(a) == a);
62 BOOST_TEST(example::what(a)() == a);
63 BOOST_TEST(example::what(arg1)(a) == a);
64 BOOST_TEST(example::what0_int() == 100);
65 BOOST_TEST(example::what0()() == 100);
66
67 return boost::report_errors();
68 }