Advertisement
Guest User

Untitled

a guest
Jun 17th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. // 2/3 / 1/6 = 4/1
  2. static_assert(
  3. std::is_same<
  4. std::ratio_divide<
  5. std::ratio<2, 3>::type,
  6. std::ratio<1, 6>::type
  7. >::type,
  8. std::ratio<4, 1>::type
  9. >::value,
  10. "ratio_divide does not work correctly");
  11.  
  12. // 2/3 * 1/6 = 1/9
  13. static_assert(
  14. std::is_same<
  15. std::ratio_multiply<
  16. std::ratio<2, 3>::type,
  17. std::ratio<1, 6>::type
  18. >::type,
  19. std::ratio<1, 9>::type
  20. >::value,
  21. "ratio_multiply does not work correctly");
  22.  
  23. // 2/3 + 1/6 = 5/6
  24. static_assert(
  25. std::is_same<
  26. std::ratio_add<
  27. std::ratio<2, 3>::type,
  28. std::ratio<1, 6>::type
  29. >::type,
  30. std::ratio<5, 6>::type
  31. >::value,
  32. "ratio_add does not work correctly");
  33.  
  34. // 2/3 - 1/6 = 1/2
  35. static_assert(
  36. std::is_same<
  37. std::ratio_subtract<
  38. std::ratio<2, 3>::type,
  39. std::ratio<1, 6>::type
  40. >::type,
  41. std::ratio<1, 2>::type
  42. >::value,
  43. "ratio_subtract does not work correctly");
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement