1 //===----------------------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
8
9 // <chrono>
10
11 // template <class Rep1, class Period1, class Rep2, class Period2>
12 // struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
13 // {
14 // typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type;
15 // };
16
17 #include <chrono>
18
19 #include "test_macros.h"
20
21 template <class D1, class D2, class De>
22 void
test()23 test()
24 {
25 typedef typename std::common_type<D1, D2>::type Dc;
26 static_assert((std::is_same<Dc, De>::value), "");
27 }
28
main(int,char **)29 int main(int, char**)
30 {
31 test<std::chrono::duration<int, std::ratio<1, 100> >,
32 std::chrono::duration<long, std::ratio<1, 1000> >,
33 std::chrono::duration<long, std::ratio<1, 1000> > >();
34 test<std::chrono::duration<long, std::ratio<1, 100> >,
35 std::chrono::duration<int, std::ratio<1, 1000> >,
36 std::chrono::duration<long, std::ratio<1, 1000> > >();
37 test<std::chrono::duration<char, std::ratio<1, 30> >,
38 std::chrono::duration<short, std::ratio<1, 1000> >,
39 std::chrono::duration<int, std::ratio<1, 3000> > >();
40 test<std::chrono::duration<double, std::ratio<21, 1> >,
41 std::chrono::duration<short, std::ratio<15, 1> >,
42 std::chrono::duration<double, std::ratio<3, 1> > >();
43
44 return 0;
45 }
46