test_optional_compat.cpp 897 B

12345678910111213141516171819202122232425262728293031
  1. /*
  2. * (c) Copyright Andrey Semashev 2018.
  3. *
  4. * Use, modification and distribution are subject to the
  5. * Boost Software License, Version 1.0. (See accompanying file
  6. * LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. /*
  9. * The test verifies that Boost.Multiprecision does not cause conflict with Boost.Optional
  10. * because of its restricted conversion constructors and operators. See comments in:
  11. *
  12. * https://github.com/boostorg/integer/pull/11
  13. */
  14. #include <boost/multiprecision/cpp_int.hpp>
  15. #include <boost/optional/optional.hpp>
  16. #include <boost/core/lightweight_test.hpp>
  17. inline boost::optional<boost::multiprecision::int128_t> foo()
  18. {
  19. return boost::optional<boost::multiprecision::int128_t>(10);
  20. }
  21. int main()
  22. {
  23. boost::optional<boost::multiprecision::int128_t> num = foo();
  24. BOOST_TEST(!!num);
  25. BOOST_TEST(*num == 10);
  26. return boost::report_errors();
  27. }