optional_test_msvc_bug_workaround.cpp 860 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  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. #define BOOST_OPTIONAL_CONFIG_NO_RVALUE_REFERENCES
  12. #include "boost/optional/optional.hpp"
  13. #ifdef __BORLANDC__
  14. #pragma hdrstop
  15. #endif
  16. #include "boost/core/lightweight_test.hpp"
  17. struct Wrapper
  18. {
  19. operator int () { return 9; }
  20. operator boost::optional<int> () { return 7; }
  21. };
  22. void test()
  23. {
  24. #if (!defined BOOST_NO_CXX11_RVALUE_REFERENCES)
  25. boost::optional<int> v = Wrapper();
  26. BOOST_TEST(v);
  27. BOOST_TEST_EQ(*v, 7);
  28. #endif
  29. }
  30. int main()
  31. {
  32. test();
  33. return boost::report_errors();
  34. }