optional_test_ref_fail_assign_from_Trefref.cpp 685 B

1234567891011121314151617181920212223242526
  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. #ifndef BOOST_NO_CXX11_RVALUE_REFERENCES
  14. //
  15. // THIS TEST SHOULD FAIL TO COMPILE
  16. //
  17. void optional_reference__test_no_assign_from_Trefref()
  18. {
  19. boost::optional<const int&> opt;
  20. opt = int(3);
  21. }
  22. #else
  23. # error "Test skipped. This cannot be implemented w/o rvalue references."
  24. #endif