common_type_duration_pass.cpp 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  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. #include <boost/chrono/chrono.hpp>
  14. #include <boost/type_traits/is_same.hpp>
  15. #if !defined(BOOST_NO_CXX11_STATIC_ASSERT)
  16. #define NOTHING ""
  17. #endif
  18. template <class D1, class D2, class De>
  19. void
  20. test()
  21. {
  22. typedef typename boost::common_type<D1, D2>::type Dc;
  23. BOOST_CHRONO_STATIC_ASSERT((boost::is_same<Dc, De>::value), NOTHING, (D1, D2, Dc, De));
  24. }
  25. void testall()
  26. {
  27. test<boost::chrono::duration<int, boost::ratio<1, 100> >,
  28. boost::chrono::duration<long, boost::ratio<1, 1000> >,
  29. boost::chrono::duration<long, boost::ratio<1, 1000> > >();
  30. test<boost::chrono::duration<long, boost::ratio<1, 100> >,
  31. boost::chrono::duration<int, boost::ratio<1, 1000> >,
  32. boost::chrono::duration<long, boost::ratio<1, 1000> > >();
  33. test<boost::chrono::duration<char, boost::ratio<1, 30> >,
  34. boost::chrono::duration<short, boost::ratio<1, 1000> >,
  35. boost::chrono::duration<int, boost::ratio<1, 3000> > >();
  36. test<boost::chrono::duration<double, boost::ratio<21, 1> >,
  37. boost::chrono::duration<short, boost::ratio<15, 1> >,
  38. boost::chrono::duration<double, boost::ratio<3, 1> > >();
  39. }