optional_test_equals_none.cpp 1.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include "boost/optional/optional.hpp"
  12. #ifdef __BORLANDC__
  13. #pragma hdrstop
  14. #endif
  15. #include "boost/core/lightweight_test.hpp"
  16. #include "boost/none.hpp"
  17. struct SemiRegular // no operator==
  18. {
  19. private: void operator==(SemiRegular const&) const {}
  20. private: void operator!=(SemiRegular const&) const {}
  21. };
  22. void test_equal_to_none_of_noncomparable_T()
  23. {
  24. boost::optional<SemiRegular> i = SemiRegular();
  25. boost::optional<SemiRegular> o;
  26. BOOST_TEST(i != boost::none);
  27. BOOST_TEST(boost::none != i);
  28. BOOST_TEST(o == boost::none);
  29. BOOST_TEST(boost::none == o);
  30. }
  31. int main()
  32. {
  33. test_equal_to_none_of_noncomparable_T();
  34. return boost::report_errors();
  35. }