Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 1 | //===----------------------------------------------------------------------===// |
| 2 | // |
Howard Hinnant | 5b08a8a | 2010-05-11 21:36:01 +0000 | [diff] [blame] | 3 | // The LLVM Compiler Infrastructure |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 4 | // |
Howard Hinnant | 412dbeb | 2010-11-16 22:09:02 +0000 | [diff] [blame] | 5 | // This file is dual licensed under the MIT and the University of Illinois Open |
| 6 | // Source Licenses. See LICENSE.TXT for details. |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 7 | // |
| 8 | //===----------------------------------------------------------------------===// |
| 9 | |
| 10 | // <chrono> |
| 11 | |
Howard Hinnant | 94b2dd0 | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 12 | // template <class Rep1, class Period1, class Rep2, class Period2> |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 13 | // struct common_type<chrono::duration<Rep1, Period1>, chrono::duration<Rep2, Period2>> |
| 14 | // { |
Howard Hinnant | 94b2dd0 | 2010-08-22 00:59:46 +0000 | [diff] [blame] | 15 | // typedef chrono::duration<typename common_type<Rep1, Rep2>::type, see below }> type; |
Howard Hinnant | 3e51952 | 2010-05-11 19:42:16 +0000 | [diff] [blame] | 16 | // }; |
| 17 | |
| 18 | #include <chrono> |
| 19 | |
| 20 | template <class D1, class D2, class De> |
| 21 | void |
| 22 | test() |
| 23 | { |
| 24 | typedef typename std::common_type<D1, D2>::type Dc; |
| 25 | static_assert((std::is_same<Dc, De>::value), ""); |
| 26 | } |
| 27 | |
| 28 | int 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 | } |