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 //===----------------------------------------------------------------------===//
12 #include "test_macros.h"
18 TEST_CONSTEXPR
Rep() : data_(-1) {}
19 explicit TEST_CONSTEXPR
Rep(int i
) : data_(i
) {}
21 bool TEST_CONSTEXPR
operator==(int i
) const {return data_
== i
;}
22 bool TEST_CONSTEXPR
operator==(const Rep
& r
) const {return data_
== r
.data_
;}
24 Rep
& operator*=(Rep x
) {data_
*= x
.data_
; return *this;}
25 Rep
& operator/=(Rep x
) {data_
/= x
.data_
; return *this;}
32 // std::chrono:::duration has only '*', '/' and '%' taking a "Rep" parameter
34 // Multiplication is commutative, division is not.
35 template <class Rep
, class Period
>
36 std::chrono::duration
<Rep
, Period
>
37 operator*(std::chrono::duration
<Rep
, Period
> d
, NotARep
) { return d
; }
39 template <class Rep
, class Period
>
40 std::chrono::duration
<Rep
, Period
>
41 operator*(NotARep
, std::chrono::duration
<Rep
, Period
> d
) { return d
; }
43 template <class Rep
, class Period
>
44 std::chrono::duration
<Rep
, Period
>
45 operator/(std::chrono::duration
<Rep
, Period
> d
, NotARep
) { return d
; }
47 template <class Rep
, class Period
>
48 std::chrono::duration
<Rep
, Period
>
49 operator%(std::chrono::duration
<Rep
, Period
> d
, NotARep
) { return d
; }
51 // op= is not commutative.
52 template <class Rep
, class Period
>
53 std::chrono::duration
<Rep
, Period
>&
54 operator*=(std::chrono::duration
<Rep
, Period
>& d
, NotARep
) { return d
; }
56 template <class Rep
, class Period
>
57 std::chrono::duration
<Rep
, Period
>&
58 operator/=(std::chrono::duration
<Rep
, Period
>& d
, NotARep
) { return d
; }
60 template <class Rep
, class Period
>
61 std::chrono::duration
<Rep
, Period
>&
62 operator%=(std::chrono::duration
<Rep
, Period
>& d
, NotARep
) { return d
; }