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);
22 #include "test_macros.h"
27 std::chrono::nanoseconds
ns1(15);
28 std::chrono::nanoseconds
ns2(6);
29 std::chrono::nanoseconds r
= ns1
% ns2
;
30 assert(r
.count() == 3);
33 std::chrono::microseconds
us1(15);
34 std::chrono::nanoseconds
ns2(28);
35 std::chrono::nanoseconds r
= us1
% ns2
;
36 assert(r
.count() == 20);
39 std::chrono::duration
<int, std::ratio
<3, 5> > s1(6);
40 std::chrono::duration
<int, std::ratio
<2, 3> > s2(3);
41 std::chrono::duration
<int, std::ratio
<1, 15> > r
= s1
% s2
;
42 assert(r
.count() == 24);
44 #if TEST_STD_VER >= 11
46 constexpr std::chrono::nanoseconds
ns1(15);
47 constexpr std::chrono::nanoseconds
ns2(6);
48 constexpr std::chrono::nanoseconds r
= ns1
% ns2
;
49 static_assert(r
.count() == 3, "");
52 constexpr std::chrono::microseconds
us1(15);
53 constexpr std::chrono::nanoseconds
ns2(28);
54 constexpr std::chrono::nanoseconds r
= us1
% ns2
;
55 static_assert(r
.count() == 20, "");
58 constexpr std::chrono::duration
<int, std::ratio
<3, 5> > s1(6);
59 constexpr std::chrono::duration
<int, std::ratio
<2, 3> > s2(3);
60 constexpr std::chrono::duration
<int, std::ratio
<1, 15> > r
= s1
% s2
;
61 static_assert(r
.count() == 24, "");