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