common_type_time_point_pass.cpp 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  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.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 boost::chrono::system_clock C;
  23. typedef boost::chrono::time_point<C, D1> T1;
  24. typedef boost::chrono::time_point<C, D2> T2;
  25. typedef boost::chrono::time_point<C, De> Te;
  26. typedef typename boost::common_type<T1, T2>::type Tc;
  27. BOOST_CHRONO_STATIC_ASSERT((boost::is_same<Tc, Te>::value), NOTHING, (T1, T2, Tc, Te));
  28. }
  29. void testall()
  30. {
  31. test<boost::chrono::duration<int, boost::ratio<1, 100> >,
  32. boost::chrono::duration<long, boost::ratio<1, 1000> >,
  33. boost::chrono::duration<long, boost::ratio<1, 1000> > >();
  34. test<boost::chrono::duration<long, boost::ratio<1, 100> >,
  35. boost::chrono::duration<int, boost::ratio<1, 1000> >,
  36. boost::chrono::duration<long, boost::ratio<1, 1000> > >();
  37. test<boost::chrono::duration<char, boost::ratio<1, 30> >,
  38. boost::chrono::duration<short, boost::ratio<1, 1000> >,
  39. boost::chrono::duration<int, boost::ratio<1, 3000> > >();
  40. test<boost::chrono::duration<double, boost::ratio<21, 1> >,
  41. boost::chrono::duration<short, boost::ratio<15, 1> >,
  42. boost::chrono::duration<double, boost::ratio<3, 1> > >();
  43. }