]>
git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/bind_nested_rv_test.cpp
1 #include <boost/config.hpp>
4 // bind_nested_rv_test.cpp
6 // Copyright (c) 2016 Peter Dimov
8 // Distributed under the Boost Software License, Version 1.0.
9 // See accompanying file LICENSE_1_0.txt or copy at
10 // http://www.boost.org/LICENSE_1_0.txt
13 #include <boost/bind/bind.hpp>
14 #include <boost/make_shared.hpp>
15 #include <boost/function.hpp>
16 #include <boost/core/lightweight_test.hpp>
18 using namespace boost::placeholders
;
22 bool f1( boost::shared_ptr
<int> p1
)
24 BOOST_TEST( p1
!= 0 && *p1
== 1 );
28 bool f2( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
)
30 BOOST_TEST( p1
!= 0 && *p1
== 1 );
31 BOOST_TEST( p2
!= 0 && *p2
== 2 );
35 bool f3( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
)
37 BOOST_TEST( p1
!= 0 && *p1
== 1 );
38 BOOST_TEST( p2
!= 0 && *p2
== 2 );
39 BOOST_TEST( p3
!= 0 && *p3
== 3 );
43 bool f4( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
, boost::shared_ptr
<int> p4
)
45 BOOST_TEST( p1
!= 0 && *p1
== 1 );
46 BOOST_TEST( p2
!= 0 && *p2
== 2 );
47 BOOST_TEST( p3
!= 0 && *p3
== 3 );
48 BOOST_TEST( p4
!= 0 && *p4
== 4 );
52 bool f5( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
, boost::shared_ptr
<int> p4
, boost::shared_ptr
<int> p5
)
54 BOOST_TEST( p1
!= 0 && *p1
== 1 );
55 BOOST_TEST( p2
!= 0 && *p2
== 2 );
56 BOOST_TEST( p3
!= 0 && *p3
== 3 );
57 BOOST_TEST( p4
!= 0 && *p4
== 4 );
58 BOOST_TEST( p5
!= 0 && *p5
== 5 );
62 bool f6( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
, boost::shared_ptr
<int> p4
, boost::shared_ptr
<int> p5
, boost::shared_ptr
<int> p6
)
64 BOOST_TEST( p1
!= 0 && *p1
== 1 );
65 BOOST_TEST( p2
!= 0 && *p2
== 2 );
66 BOOST_TEST( p3
!= 0 && *p3
== 3 );
67 BOOST_TEST( p4
!= 0 && *p4
== 4 );
68 BOOST_TEST( p5
!= 0 && *p5
== 5 );
69 BOOST_TEST( p6
!= 0 && *p6
== 6 );
73 bool f7( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
, boost::shared_ptr
<int> p4
, boost::shared_ptr
<int> p5
, boost::shared_ptr
<int> p6
, boost::shared_ptr
<int> p7
)
75 BOOST_TEST( p1
!= 0 && *p1
== 1 );
76 BOOST_TEST( p2
!= 0 && *p2
== 2 );
77 BOOST_TEST( p3
!= 0 && *p3
== 3 );
78 BOOST_TEST( p4
!= 0 && *p4
== 4 );
79 BOOST_TEST( p5
!= 0 && *p5
== 5 );
80 BOOST_TEST( p6
!= 0 && *p6
== 6 );
81 BOOST_TEST( p7
!= 0 && *p7
== 7 );
85 bool f8( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
, boost::shared_ptr
<int> p4
, boost::shared_ptr
<int> p5
, boost::shared_ptr
<int> p6
, boost::shared_ptr
<int> p7
, boost::shared_ptr
<int> p8
)
87 BOOST_TEST( p1
!= 0 && *p1
== 1 );
88 BOOST_TEST( p2
!= 0 && *p2
== 2 );
89 BOOST_TEST( p3
!= 0 && *p3
== 3 );
90 BOOST_TEST( p4
!= 0 && *p4
== 4 );
91 BOOST_TEST( p5
!= 0 && *p5
== 5 );
92 BOOST_TEST( p6
!= 0 && *p6
== 6 );
93 BOOST_TEST( p7
!= 0 && *p7
== 7 );
94 BOOST_TEST( p8
!= 0 && *p8
== 8 );
98 bool f9( boost::shared_ptr
<int> p1
, boost::shared_ptr
<int> p2
, boost::shared_ptr
<int> p3
, boost::shared_ptr
<int> p4
, boost::shared_ptr
<int> p5
, boost::shared_ptr
<int> p6
, boost::shared_ptr
<int> p7
, boost::shared_ptr
<int> p8
, boost::shared_ptr
<int> p9
)
100 BOOST_TEST( p1
!= 0 && *p1
== 1 );
101 BOOST_TEST( p2
!= 0 && *p2
== 2 );
102 BOOST_TEST( p3
!= 0 && *p3
== 3 );
103 BOOST_TEST( p4
!= 0 && *p4
== 4 );
104 BOOST_TEST( p5
!= 0 && *p5
== 5 );
105 BOOST_TEST( p6
!= 0 && *p6
== 6 );
106 BOOST_TEST( p7
!= 0 && *p7
== 7 );
107 BOOST_TEST( p8
!= 0 && *p8
== 8 );
108 BOOST_TEST( p9
!= 0 && *p9
== 9 );
115 boost::function
<bool(boost::shared_ptr
<int>)> f( f1
);
117 ( boost::bind( f
, _1
) && boost::bind( f1
, _1
) )( boost::make_shared
<int>( 1 ) );
121 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f2
);
123 ( boost::bind( f
, _1
, _2
) && boost::bind( f2
, _1
, _2
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ) );
127 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f3
);
129 ( boost::bind( f
, _1
, _2
, _3
) && boost::bind( f3
, _1
, _2
, _3
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ) );
133 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f3
);
135 ( boost::bind( f
, _1
, _2
, _3
) && boost::bind( f3
, _1
, _2
, _3
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ) );
139 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f4
);
141 ( boost::bind( f
, _1
, _2
, _3
, _4
) && boost::bind( f4
, _1
, _2
, _3
, _4
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ), boost::make_shared
<int>( 4 ) );
145 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f5
);
147 ( boost::bind( f
, _1
, _2
, _3
, _4
, _5
) && boost::bind( f5
, _1
, _2
, _3
, _4
, _5
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ), boost::make_shared
<int>( 4 ), boost::make_shared
<int>( 5 ) );
151 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f6
);
153 ( boost::bind( f
, _1
, _2
, _3
, _4
, _5
, _6
) && boost::bind( f6
, _1
, _2
, _3
, _4
, _5
, _6
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ), boost::make_shared
<int>( 4 ), boost::make_shared
<int>( 5 ), boost::make_shared
<int>( 6 ) );
157 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f7
);
159 ( boost::bind( f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
) && boost::bind( f7
, _1
, _2
, _3
, _4
, _5
, _6
, _7
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ), boost::make_shared
<int>( 4 ), boost::make_shared
<int>( 5 ), boost::make_shared
<int>( 6 ), boost::make_shared
<int>( 7 ) );
163 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f8
);
165 ( boost::bind( f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
) && boost::bind( f8
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ), boost::make_shared
<int>( 4 ), boost::make_shared
<int>( 5 ), boost::make_shared
<int>( 6 ), boost::make_shared
<int>( 7 ), boost::make_shared
<int>( 8 ) );
169 boost::function
<bool(boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>, boost::shared_ptr
<int>)> f( f9
);
171 ( boost::bind( f
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
, _9
) && boost::bind( f9
, _1
, _2
, _3
, _4
, _5
, _6
, _7
, _8
, _9
) )( boost::make_shared
<int>( 1 ), boost::make_shared
<int>( 2 ), boost::make_shared
<int>( 3 ), boost::make_shared
<int>( 4 ), boost::make_shared
<int>( 5 ), boost::make_shared
<int>( 6 ), boost::make_shared
<int>( 7 ), boost::make_shared
<int>( 8 ), boost::make_shared
<int>( 9 ) );
178 return boost::report_errors();