1 | //===- llvm/unittest/ADT/MoveOnly.h - Optional unit tests -----------------===// |
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 | //===----------------------------------------------------------------------===// |
8 | |
9 | #ifndef LLVM_UNITTESTS_ADT_MOVEONLY_H |
10 | #define LLVM_UNITTESTS_ADT_MOVEONLY_H |
11 | |
12 | namespace llvm { |
13 | |
14 | struct MoveOnly { |
15 | static unsigned MoveConstructions; |
16 | static unsigned Destructions; |
17 | static unsigned MoveAssignments; |
18 | int val; |
19 | explicit MoveOnly(int val) : val(val) { |
20 | } |
21 | MoveOnly(MoveOnly&& other) { |
22 | val = other.val; |
23 | ++MoveConstructions; |
24 | } |
25 | MoveOnly &operator=(MoveOnly&& other) { |
26 | val = other.val; |
27 | ++MoveAssignments; |
28 | return *this; |
29 | } |
30 | ~MoveOnly() { |
31 | ++Destructions; |
32 | } |
33 | static void ResetCounts() { |
34 | MoveConstructions = 0; |
35 | Destructions = 0; |
36 | MoveAssignments = 0; |
37 | } |
38 | }; |
39 | |
40 | } // end namespace llvm |
41 | |
42 | #endif // LLVM_UNITTESTS_ADT_MOVEONLY_H |
43 | |