optional_xconfig_NO_PROPER_ASSIGN_FROM_CONST_INT_fail.cpp 824 B

123456789101112131415161718192021222324252627282930313233343536373839404142
  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 "boost/core/lightweight_test.hpp"
  12. #include "boost/optional/detail/optional_config.hpp"
  13. #ifndef BOOST_OPTIONAL_CONFIG_NO_PROPER_ASSIGN_FROM_CONST_INT
  14. int main()
  15. {
  16. BOOST_ERROR("failed as requested");
  17. return boost::report_errors();
  18. }
  19. #else
  20. const int global_i = 0;
  21. struct Binder
  22. {
  23. void operator=(const int& i)
  24. {
  25. BOOST_TEST(&i == &global_i);
  26. }
  27. };
  28. int main()
  29. {
  30. Binder s;
  31. s = global_i;
  32. return boost::report_errors();
  33. }
  34. #endif