]>
Commit | Line | Data |
---|---|---|
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_compile_fail_conv_pvoid.cpp | |
9 | * \author Andrey Semashev | |
10 | * \date 17.07.2010 | |
11 | * | |
12 | * \brief This test checks that explicit operator bool cannot be used in | |
13 | * an unintended context. | |
14 | */ | |
15 | ||
16 | #define BOOST_TEST_MODULE explicit_operator_bool_compile_fail_conv_pvoid | |
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 checkable | |
24 | { | |
25 | BOOST_EXPLICIT_OPERATOR_BOOL() | |
26 | bool operator! () const | |
27 | { | |
28 | return false; | |
29 | } | |
30 | }; | |
31 | ||
32 | } // namespace | |
33 | ||
34 | int main(int, char*[]) | |
35 | { | |
36 | checkable val; | |
37 | void* p = val; | |
38 | (void)p; | |
39 | ||
40 | return 0; | |
41 | } |