mpl_times_pass.cpp 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  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::times
  14. #define BOOST_RATIO_EXTENSIONS
  15. #include <boost/ratio/mpl/times.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. typedef boost::mpl::times<R1, R2> R;
  25. BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 1, NOTHING, ());
  26. }
  27. {
  28. typedef boost::ratio<1, 2> R1;
  29. typedef boost::ratio<1, 1> R2;
  30. typedef boost::mpl::times<R1, R2> R;
  31. BOOST_RATIO_STATIC_ASSERT(R::num == 1 && R::den == 2, NOTHING, ());
  32. }
  33. {
  34. typedef boost::ratio<-1, 2> R1;
  35. typedef boost::ratio<1, 1> R2;
  36. typedef boost::mpl::times<R1, R2> R;
  37. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  38. }
  39. {
  40. typedef boost::ratio<1, -2> R1;
  41. typedef boost::ratio<1, 1> R2;
  42. typedef boost::mpl::times<R1, R2> R;
  43. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  44. }
  45. {
  46. typedef boost::ratio<1, 2> R1;
  47. typedef boost::ratio<-1, 1> R2;
  48. typedef boost::mpl::times<R1, R2> R;
  49. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  50. }
  51. {
  52. typedef boost::ratio<1, 2> R1;
  53. typedef boost::ratio<1, -1> R2;
  54. typedef boost::mpl::times<R1, R2> R;
  55. BOOST_RATIO_STATIC_ASSERT(R::num == -1 && R::den == 2, NOTHING, ());
  56. }
  57. {
  58. typedef boost::ratio<56987354, 467584654> R1;
  59. typedef boost::ratio<544668, 22145> R2;
  60. typedef boost::mpl::times<R1, R2> R;
  61. BOOST_RATIO_STATIC_ASSERT(R::num == 15519594064236LL && R::den == 5177331081415LL, NOTHING, ());
  62. }
  63. }