explicit_operator_bool_compile_fail_shift.cpp 904 B

12345678910111213141516171819202122232425262728293031323334353637383940
  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. #define BOOST_TEST_MODULE explicit_operator_bool_compile_fail_shift
  16. #include <boost/utility/explicit_operator_bool.hpp>
  17. namespace {
  18. // A test object that has the operator of explicit conversion to bool
  19. struct checkable
  20. {
  21. BOOST_EXPLICIT_OPERATOR_BOOL()
  22. bool operator! () const
  23. {
  24. return false;
  25. }
  26. };
  27. } // namespace
  28. int main(int, char*[])
  29. {
  30. checkable val;
  31. val << 2;
  32. return 0;
  33. }