Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / libcxx / test / std / time / rep.h
blob80a0e3c54571841265b366f1762f1434db7daf6a
1 //===----------------------------------------------------------------------===//
2 //
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
6 //
7 //===----------------------------------------------------------------------===//
9 #ifndef REP_H
10 #define REP_H
12 #include "test_macros.h"
14 class Rep
16 int data_;
17 public:
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;}
28 // This is PR#41130
30 struct NotARep {};
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; }
64 #endif // REP_H