]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/test/explicit_operator_bool.cpp
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / core / test / explicit_operator_bool.cpp
1 /*
2 * Copyright Andrey Semashev 2007 - 2013.
3 * Distributed under the Boost Software License, Version 1.0.
4 * (See accompanying file LICENSE_1_0.txt or copy at
5 * http://www.boost.org/LICENSE_1_0.txt)
6 */
7 /*!
8 * \file explicit_operator_bool.cpp
9 * \author Andrey Semashev
10 * \date 17.07.2010
11 *
12 * \brief This test checks that explicit operator bool can be used in
13 * the valid contexts.
14 */
15
16 #define BOOST_TEST_MODULE explicit_operator_bool
17
18 #include <boost/utility/explicit_operator_bool.hpp>
19
20 namespace {
21
22 // A test object that has the operator of explicit conversion to bool
23 struct checkable1
24 {
25 BOOST_EXPLICIT_OPERATOR_BOOL()
26 bool operator! () const
27 {
28 return false;
29 }
30 };
31
32 struct checkable2
33 {
34 BOOST_CONSTEXPR_EXPLICIT_OPERATOR_BOOL()
35 BOOST_CONSTEXPR bool operator! () const
36 {
37 return false;
38 }
39 };
40
41 } // namespace
42
43 int main(int, char*[])
44 {
45 checkable1 val1;
46 if (val1)
47 {
48 checkable2 val2;
49 if (val2)
50 return 0;
51 }
52
53 return 1;
54 }