optional_test_fail_io_without_io.cpp 710 B

123456789101112131415161718192021222324
  1. // Copyright (C) 2015, 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. #include <iostream>
  12. #include "boost/optional.hpp"
  13. // but no boost/optional/optional_io.hpp
  14. // THIS TEST SHOULD FAIL TO COMPILE
  15. // Unless one includes header boost/optional/optional_io.hpp, it should not be possible
  16. // to stream out an optional object.
  17. void test_streaming_out_optional()
  18. {
  19. boost::optional<int> opt;
  20. std::cout << opt;
  21. }