]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/bind/test/bind_and_or_test.cpp
bump version to 18.2.4-pve3
[ceph.git] / ceph / src / boost / libs / bind / test / bind_and_or_test.cpp
1 #include <boost/config.hpp>
2
3 #if defined(BOOST_MSVC)
4 #pragma warning(disable: 4786) // identifier truncated in debug info
5 #pragma warning(disable: 4710) // function not inlined
6 #pragma warning(disable: 4711) // function selected for automatic inline expansion
7 #pragma warning(disable: 4514) // unreferenced inline removed
8 #endif
9
10 //
11 // bind_and_or_test.cpp - &&, || operators
12 //
13 // Copyright (c) 2008 Peter Dimov
14 //
15 // Distributed under the Boost Software License, Version 1.0. (See
16 // accompanying file LICENSE_1_0.txt or copy at
17 // http://www.boost.org/LICENSE_1_0.txt)
18 //
19
20 #include <boost/bind/bind.hpp>
21 #include <boost/core/lightweight_test.hpp>
22
23 using namespace boost::placeholders;
24
25 //
26
27 bool f( bool x )
28 {
29 return x;
30 }
31
32 bool g( bool x )
33 {
34 return !x;
35 }
36
37 bool h()
38 {
39 BOOST_ERROR( "Short-circuit evaluation failure" );
40 return false;
41 }
42
43 template< class F, class A1, class A2, class R > void test( F f, A1 a1, A2 a2, R r )
44 {
45 BOOST_TEST( f( a1, a2 ) == r );
46 }
47
48 int main()
49 {
50 // &&
51
52 test( boost::bind( f, true ) && boost::bind( g, true ), false, false, f( true ) && g( true ) );
53 test( boost::bind( f, true ) && boost::bind( g, false ), false, false, f( true ) && g( false ) );
54
55 test( boost::bind( f, false ) && boost::bind( h ), false, false, f( false ) && h() );
56
57 test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, true, f( true ) && g( true ) );
58 test( boost::bind( f, _1 ) && boost::bind( g, _2 ), true, false, f( true ) && g( false ) );
59
60 test( boost::bind( f, _1 ) && boost::bind( h ), false, false, f( false ) && h() );
61
62 // ||
63
64 test( boost::bind( f, false ) || boost::bind( g, true ), false, false, f( false ) || g( true ) );
65 test( boost::bind( f, false ) || boost::bind( g, false ), false, false, f( false ) || g( false ) );
66
67 test( boost::bind( f, true ) || boost::bind( h ), false, false, f( true ) || h() );
68
69 test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, true, f( false ) || g( true ) );
70 test( boost::bind( f, _1 ) || boost::bind( g, _2 ), false, false, f( false ) || g( false ) );
71
72 test( boost::bind( f, _1 ) || boost::bind( h ), true, false, f( true ) || h() );
73
74 //
75
76 return boost::report_errors();
77 }