mpl_equal_to_pass.cpp 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. //===----------------------------------------------------------------------===//
  2. //
  3. // The LLVM Compiler Infrastructure
  4. //
  5. // This file is dual licensed under the MIT and the University of Illinois Open
  6. // Source Licenses. See LICENSE.TXT for details.
  7. //
  8. //===----------------------------------------------------------------------===//
  9. // Adaptation to Boost of the libcxx
  10. // Copyright 2010 Vicente J. Botet Escriba
  11. // Distributed under the Boost Software License, Version 1.0.
  12. // See http://www.boost.org/LICENSE_1_0.txt
  13. // test mpl::equal_to
  14. #define BOOST_RATIO_EXTENSIONS
  15. #include <boost/ratio/mpl/equal_to.hpp>
  16. #if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
  17. #define NOTHING ""
  18. #endif
  19. void test()
  20. {
  21. {
  22. typedef boost::ratio<1, 1> R1;
  23. typedef boost::ratio<1, 1> R2;
  24. BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  25. }
  26. {
  27. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  28. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  29. BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  30. }
  31. {
  32. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  33. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  34. BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  35. }
  36. {
  37. typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
  38. typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R2;
  39. BOOST_RATIO_STATIC_ASSERT((boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  40. }
  41. {
  42. typedef boost::ratio<1, 1> R1;
  43. typedef boost::ratio<1, -1> R2;
  44. BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  45. }
  46. {
  47. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  48. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  49. BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  50. }
  51. {
  52. typedef boost::ratio<-BOOST_RATIO_INTMAX_T_MAX, 1> R1;
  53. typedef boost::ratio<BOOST_RATIO_INTMAX_T_MAX, 1> R2;
  54. BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  55. }
  56. {
  57. typedef boost::ratio<1, BOOST_RATIO_INTMAX_T_MAX> R1;
  58. typedef boost::ratio<1, -BOOST_RATIO_INTMAX_T_MAX> R2;
  59. BOOST_RATIO_STATIC_ASSERT((!boost::mpl::equal_to<R1, R2>::value), NOTHING, ());
  60. }
  61. }