optional_test_fail_implicit_bool_convert.cpp 693 B

12345678910111213141516171819202122232425262728
  1. // Copyright (C) 2014, Andrzej Krzemienski.
  2. //
  3. // Use, modification, and distribution is subject to the Boost Software
  4. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  5. // http://www.boost.org/LICENSE_1_0.txt)
  6. //
  7. // See http://www.boost.org/lib/optional for documentation.
  8. //
  9. // You are welcome to contact the author at:
  10. // akrzemi1@gmail.com
  11. //
  12. #include "boost/optional.hpp"
  13. //
  14. // THIS TEST SHOULD FAIL TO COMPILE
  15. //
  16. #if !defined(BOOST_NO_CXX11_EXPLICIT_CONVERSION_OPERATORS)
  17. bool test_implicit_conversion_to_bool()
  18. {
  19. boost::optional<int> opt;
  20. return opt;
  21. }
  22. #else
  23. # error "Test skipped: this compiler does not support explicit conversion operators."
  24. #endif