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_shift.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_shift 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 main(int,char * [])34int main(int, char*[]) 35 { 36 checkable val; 37 val << 2; 38 39 return 0; 40 } 41