blob: f942844b60a64dd03d1cf330da90c34155a57edd [file] [log] [blame]
Howard Hinnant3e519522010-05-11 19:42:16 +00001//===----------------------------------------------------------------------===//
2//
Howard Hinnant5b08a8a2010-05-11 21:36:01 +00003// The LLVM Compiler Infrastructure
Howard Hinnant3e519522010-05-11 19:42:16 +00004//
Howard Hinnant412dbeb2010-11-16 22:09:02 +00005// This file is dual licensed under the MIT and the University of Illinois Open
6// Source Licenses. See LICENSE.TXT for details.
Howard Hinnant3e519522010-05-11 19:42:16 +00007//
8//===----------------------------------------------------------------------===//
9
10// <chrono>
11
Howard Hinnant94b2dd02010-08-22 00:59:46 +000012// template <class Rep1, class Period1, class Rep2, class Period2>
Howard Hinnant3e519522010-05-11 19:42:16 +000013// struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>>
14// {
Howard Hinnant94b2dd02010-08-22 00:59:46 +000015// typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type;
Howard Hinnant3e519522010-05-11 19:42:16 +000016// };
17
18#include <chrono>
19
20template <class D1, class D2, class De>
21void
22test()
23{
24 typedef typename std::common_type<D1, D2>::type Dc;
25 static_assert((std::is_same<Dc, De>::value), "");
26}
27
28int 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}