| 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 |
#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 typename std::common_type<D1, D2>::type Dc; |
| 28 |
static_assert((std::is_same<Dc, De>::value), ""); |
| 29 |
} |
| 30 |
|
| 31 |
int main(int, char**) |
| 32 |
{ |
| 33 |
test<std::chrono::duration<int, std::ratio<1, 100> >, |
| 34 |
std::chrono::duration<long, std::ratio<1, 1000> >, |
| 35 |
std::chrono::duration<long, std::ratio<1, 1000> > >(); |
| 36 |
test<std::chrono::duration<long, std::ratio<1, 100> >, |
| 37 |
std::chrono::duration<int, std::ratio<1, 1000> >, |
| 38 |
std::chrono::duration<long, std::ratio<1, 1000> > >(); |
| 39 |
test<std::chrono::duration<char, std::ratio<1, 30> >, |
| 40 |
std::chrono::duration<short, std::ratio<1, 1000> >, |
| 41 |
std::chrono::duration<int, std::ratio<1, 3000> > >(); |
| 42 |
test<std::chrono::duration<double, std::ratio<21, 1> >, |
| 43 |
std::chrono::duration<short, std::ratio<15, 1> >, |
| 44 |
std::chrono::duration<double, std::ratio<3, 1> > >(); |
| 45 |
|
| 46 |
return 0; |
| 47 |
} |