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 10 // <chrono> 11 12 // template <class Clock, class Duration1, class Duration2> 13 // struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>> 14 // { 15 // typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type; 16 // }; 17 18 #include <chrono> 19 20 template <class D1, class D2, class De> 21 void 22 test() 23 { 24 typedef std::chrono::system_clock C; 25 typedef std::chrono::time_point<C, D1> T1; 26 typedef std::chrono::time_point<C, D2> T2; 27 typedef std::chrono::time_point<C, De> Te; 28 typedef typename std::common_type<T1, T2>::type Tc; 29 static_assert((std::is_same<Tc, Te>::value), ""); 30 } 31 32 int main() 33 { 34 test<std::chrono::duration<int, std::ratio<1, 100> >, 35 std::chrono::duration<long, std::ratio<1, 1000> >, 36 std::chrono::duration<long, std::ratio<1, 1000> > >(); 37 test<std::chrono::duration<long, std::ratio<1, 100> >, 38 std::chrono::duration<int, std::ratio<1, 1000> >, 39 std::chrono::duration<long, std::ratio<1, 1000> > >(); 40 test<std::chrono::duration<char, std::ratio<1, 30> >, 41 std::chrono::duration<short, std::ratio<1, 1000> >, 42 std::chrono::duration<int, std::ratio<1, 3000> > >(); 43 test<std::chrono::duration<double, std::ratio<21, 1> >, 44 std::chrono::duration<short, std::ratio<15, 1> >, 45 std::chrono::duration<double, std::ratio<3, 1> > >(); 46 } 47