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 Rep1, class Period1, class Rep2, class Period2>
13 // struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
14 // {
15 //     typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type;
16 // };
17 
18 #include <chrono>
19 
20 template <class D1, class D2, class De>
21 void
test()22 test()
23 {
24     typedef typename std::common_type<D1, D2>::type Dc;
25     static_assert((std::is_same<Dc, De>::value), "");
26 }
27 
main()28 int main()
29 {
30     test<std::chrono::duration<int, std::ratio<1, 100> >,
31          std::chrono::duration<long, std::ratio<1, 1000> >,
32          std::chrono::duration<long, std::ratio<1, 1000> > >();
33     test<std::chrono::duration<long, std::ratio<1, 100> >,
34          std::chrono::duration<int, std::ratio<1, 1000> >,
35          std::chrono::duration<long, std::ratio<1, 1000> > >();
36     test<std::chrono::duration<char, std::ratio<1, 30> >,
37          std::chrono::duration<short, std::ratio<1, 1000> >,
38          std::chrono::duration<int, std::ratio<1, 3000> > >();
39     test<std::chrono::duration<double, std::ratio<21, 1> >,
40          std::chrono::duration<short, std::ratio<15, 1> >,
41          std::chrono::duration<double, std::ratio<3, 1> > >();
42 }
43