optional_test_assign.cpp 737 B

123456789101112131415161718192021222324252627282930
  1. // Copyright (C) 2018 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 "boost/core/lightweight_test.hpp"
  12. #include "boost/optional/optional.hpp"
  13. void test_assignment_to_empty()
  14. {
  15. // this test used to fail on GCC 8.1.0/8.2.0/9.0.0 with -std=c++98
  16. boost::optional<int> oa, ob(1);
  17. BOOST_TEST(!oa);
  18. BOOST_TEST(ob);
  19. oa = ob;
  20. BOOST_TEST(oa);
  21. }
  22. int main()
  23. {
  24. test_assignment_to_empty();
  25. return boost::report_errors();
  26. }