compressed_pair_final_test.cpp 899 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. /*
  2. Copyright 2018 Glen Joseph Fernandes
  3. (glenjofe@gmail.com)
  4. Distributed under the Boost Software License, Version 1.0.
  5. (http://www.boost.org/LICENSE_1_0.txt)
  6. */
  7. #include <boost/config.hpp>
  8. #if !defined(BOOST_NO_CXX11_FINAL)
  9. #include <boost/compressed_pair.hpp>
  10. #include <boost/core/lightweight_test.hpp>
  11. struct type1 {
  12. operator bool() const {
  13. return false;
  14. }
  15. };
  16. struct type2 final {
  17. operator bool() const {
  18. return false;
  19. }
  20. };
  21. #if !defined(BOOST_IS_FINAL)
  22. namespace boost {
  23. template<>
  24. struct is_final<type2>
  25. : true_type { };
  26. } /* boost*/
  27. #endif
  28. template<class T1, class T2>
  29. void test()
  30. {
  31. boost::compressed_pair<T1, T2> p;
  32. BOOST_TEST(!p.first());
  33. BOOST_TEST(!p.second());
  34. }
  35. int main()
  36. {
  37. test<type1, type2>();
  38. test<type2, type1>();
  39. test<type2, type2>();
  40. return boost::report_errors();
  41. }
  42. #else
  43. int main()
  44. {
  45. return 0;
  46. }
  47. #endif