1 //===----------------------------------------------------------------------===//
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
7 //===----------------------------------------------------------------------===//
11 // template <class Clock, class Duration1, class Duration2>
12 // struct common_type<chrono::time_point<Clock, Duration1>, chrono::time_point<Clock, Duration2>>
14 // typedef chrono::time_point<Clock, typename common_type<Duration1, Duration2>::type> type;
19 #include <type_traits>
21 #include "test_macros.h"
23 template <class D1
, class D2
, class De
>
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
), "");
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> > >();