optional_test_fail2.cpp 660 B

1234567891011121314151617181920212223242526
  1. // Copyright (C) 2003, Fernando Luis Cacciola Carballal.
  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. // fernando_cacciola@hotmail.com
  11. //
  12. #include "boost/optional.hpp"
  13. //
  14. // THIS TEST SHOULD FAIL TO COMPILE
  15. //
  16. void test_no_implicit_conversion()
  17. {
  18. boost::optional<int> opt(1) ;
  19. // You can compare against 0 or against another optional<>,
  20. // but not against another value
  21. if ( opt == 1 ) ;
  22. }