optional_test_fail_const_swap.cpp 693 B

1234567891011121314151617181920212223242526
  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/optional.hpp"
  12. // THIS TEST SHOULD FAIL TO COMPILE
  13. void test_converitng_assignment_of_different_enums()
  14. {
  15. const boost::optional<int> o1(1);
  16. const boost::optional<int> o2(2);
  17. swap(o1, o2); // no swap on const objects should compile
  18. }
  19. int main()
  20. {
  21. test_converitng_assignment_of_different_enums();
  22. }