1 //===----------------------------------------------------------------------===//
2 //
3 // The LLVM Compiler Infrastructure
4 //
5 // This file is dual licensed under the MIT and the University of Illinois Open
6 // Source Licenses. See LICENSE.TXT for details.
7 //
8 //===----------------------------------------------------------------------===//
9
10 // <chrono>
11
12 // duration
13
14 // template <class Rep1, class Period1, class Rep2, class Period2>
15 // constexpr
16 // typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
17 // operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
18
19 #include <chrono>
20 #include <cassert>
21
main()22 int main()
23 {
24 {
25 std::chrono::nanoseconds ns1(15);
26 std::chrono::nanoseconds ns2(6);
27 std::chrono::nanoseconds r = ns1 % ns2;
28 assert(r.count() == 3);
29 }
30 {
31 std::chrono::microseconds us1(15);
32 std::chrono::nanoseconds ns2(28);
33 std::chrono::nanoseconds r = us1 % ns2;
34 assert(r.count() == 20);
35 }
36 {
37 std::chrono::duration<int, std::ratio<3, 5> > s1(6);
38 std::chrono::duration<int, std::ratio<2, 3> > s2(3);
39 std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
40 assert(r.count() == 24);
41 }
42 #ifndef _LIBCPP_HAS_NO_CONSTEXPR
43 {
44 constexpr std::chrono::nanoseconds ns1(15);
45 constexpr std::chrono::nanoseconds ns2(6);
46 constexpr std::chrono::nanoseconds r = ns1 % ns2;
47 static_assert(r.count() == 3, "");
48 }
49 {
50 constexpr std::chrono::microseconds us1(15);
51 constexpr std::chrono::nanoseconds ns2(28);
52 constexpr std::chrono::nanoseconds r = us1 % ns2;
53 static_assert(r.count() == 20, "");
54 }
55 {
56 constexpr std::chrono::duration<int, std::ratio<3, 5> > s1(6);
57 constexpr std::chrono::duration<int, std::ratio<2, 3> > s2(3);
58 constexpr std::chrono::duration<int, std::ratio<1, 15> > r = s1 % s2;
59 static_assert(r.count() == 24, "");
60 }
61 #endif
62 }
63