common_type_6_test.cpp 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. // Copyright Peter Dimov 2015
  2. // Use, modification and distribution are subject to the
  3. // Boost Software License, Version 1.0. (See accompanying file
  4. // LICENSE_1_0.txt or copy at http://www.tt.org/LICENSE_1_0.txt)
  5. #ifdef TEST_STD
  6. # include <type_traits>
  7. #else
  8. # include <boost/type_traits/common_type.hpp>
  9. #endif
  10. #include "test.hpp"
  11. #include "check_type.hpp"
  12. #include <iostream>
  13. struct X {};
  14. struct Y: X {};
  15. TT_TEST_BEGIN(common_type_6)
  16. {
  17. // binary case
  18. BOOST_CHECK_TYPE3(tt::common_type<void, void>::type, void);
  19. BOOST_CHECK_TYPE3(tt::common_type<int, int>::type, int);
  20. BOOST_CHECK_TYPE3(tt::common_type<int&, int&>::type, int);
  21. BOOST_CHECK_TYPE3(tt::common_type<int&, int const&>::type, int);
  22. BOOST_CHECK_TYPE3(tt::common_type<X, X>::type, X);
  23. BOOST_CHECK_TYPE3(tt::common_type<X&, X&>::type, X);
  24. BOOST_CHECK_TYPE3(tt::common_type<X&, X const&>::type, X);
  25. BOOST_CHECK_TYPE3(tt::common_type<X, Y>::type, X);
  26. BOOST_CHECK_TYPE3(tt::common_type<X&, Y&>::type, X);
  27. BOOST_CHECK_TYPE3(tt::common_type<X const&, Y&>::type, X);
  28. BOOST_CHECK_TYPE3(tt::common_type<X&, Y const&>::type, X);
  29. BOOST_CHECK_TYPE3(tt::common_type<X const&, Y const&>::type, X);
  30. }
  31. TT_TEST_END