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 //===----------------------------------------------------------------------===//
13 // template <class Rep1, class Period1, class Rep2, class Period2>
15 // typename common_type<duration<Rep1, Period1>, duration<Rep2, Period2>>::type
16 // operator%(const duration<Rep1, Period1>& lhs, const duration<Rep2, Period2>& rhs);
21 #include "../../rep.h"
23 #include "test_macros.h"
28 std::chrono::nanoseconds
ns1(15);
29 std::chrono::nanoseconds
ns2(6);
30 std::chrono::nanoseconds r
= ns1
% ns2
;
31 assert(r
.count() == 3);
34 std::chrono::microseconds
us1(15);
35 std::chrono::nanoseconds
ns2(28);
36 std::chrono::nanoseconds r
= us1
% ns2
;
37 assert(r
.count() == 20);
40 std::chrono::duration
<int, std::ratio
<3, 5> > s1(6);
41 std::chrono::duration
<int, std::ratio
<2, 3> > s2(3);
42 std::chrono::duration
<int, std::ratio
<1, 15> > r
= s1
% s2
;
43 assert(r
.count() == 24);
45 #if TEST_STD_VER >= 11
47 constexpr std::chrono::nanoseconds
ns1(15);
48 constexpr std::chrono::nanoseconds
ns2(6);
49 constexpr std::chrono::nanoseconds r
= ns1
% ns2
;
50 static_assert(r
.count() == 3, "");
53 constexpr std::chrono::microseconds
us1(15);
54 constexpr std::chrono::nanoseconds
ns2(28);
55 constexpr std::chrono::nanoseconds r
= us1
% ns2
;
56 static_assert(r
.count() == 20, "");
59 constexpr std::chrono::duration
<int, std::ratio
<3, 5> > s1(6);
60 constexpr std::chrono::duration
<int, std::ratio
<2, 3> > s2(3);
61 constexpr std::chrono::duration
<int, std::ratio
<1, 15> > r
= s1
% s2
;
62 static_assert(r
.count() == 24, "");
65 std::chrono::duration
<int> d(5);
66 RepConstConvertibleLWG3050 x
;
70 assert(r
.count() == 1);
71 ASSERT_SAME_TYPE(std::chrono::duration
<long>, decltype(r
));
74 #endif // TEST_STD_VER >= 11