]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/parameter/test/normalized_argument_types.cpp
update sources to v12.2.3
[ceph.git] / ceph / src / boost / libs / parameter / test / normalized_argument_types.cpp
1 // Copyright Daniel Wallin 2006. Use, modification and distribution is
2 // subject to the Boost Software License, Version 1.0. (See accompanying
3 // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
4
5 #include <boost/parameter.hpp>
6 #include <boost/mpl/assert.hpp>
7 #include <boost/type_traits/is_same.hpp>
8 #include <cassert>
9
10 struct count_instances
11 {
12 count_instances()
13 {
14 ++count;
15 }
16
17 count_instances(count_instances const&)
18 {
19 ++count;
20 }
21
22 template <class T>
23 count_instances(T const&)
24 {
25 ++count;
26 }
27
28 ~count_instances()
29 {
30 --count;
31 }
32
33 static std::size_t count;
34 };
35
36 std::size_t count_instances::count = 0;
37
38 BOOST_PARAMETER_NAME(x)
39 BOOST_PARAMETER_NAME(y)
40
41 BOOST_PARAMETER_FUNCTION((int), f, tag,
42 (required
43 (x, (int))
44 (y, (int))
45 )
46 )
47 {
48 BOOST_MPL_ASSERT((boost::is_same<x_type,int>));
49 BOOST_MPL_ASSERT((boost::is_same<y_type,int>));
50 return 0;
51 }
52
53 BOOST_PARAMETER_FUNCTION((int), g, tag,
54 (required
55 (x, (count_instances))
56 )
57 )
58 {
59 BOOST_MPL_ASSERT((boost::is_same<x_type,count_instances>));
60 assert(count_instances::count > 0);
61 return 0;
62 }
63
64 BOOST_PARAMETER_FUNCTION((int), h, tag,
65 (required
66 (x, (count_instances const&))
67 )
68 )
69 {
70 BOOST_MPL_ASSERT((boost::is_same<x_type,count_instances const>));
71 assert(count_instances::count == 1);
72 return 0;
73 }
74
75 int main()
76 {
77 f(1, 2);
78 f(1., 2.f);
79 f(1U, 2L);
80
81 g(0);
82
83 h(0);
84 }
85