MCPcopy Create free account
hub / github.com/FastLED/FastLED / MoveTestTypePair

Class MoveTestTypePair

tests/fl/stl/pair.cpp:14–54  ·  view source on GitHub ↗

Helper class to test move semantics

Source from the content-addressed store, hash-verified

12
13// Helper class to test move semantics
14struct MoveTestTypePair {
15 int value;
16 bool moved_from = false;
17 bool moved_to = false;
18
19 MoveTestTypePair() : value(0) {}
20 explicit MoveTestTypePair(int v) : value(v) {}
21
22 // Copy constructor
23 MoveTestTypePair(const MoveTestTypePair& other) : value(other.value) {}
24
25 // Move constructor
26 MoveTestTypePair(MoveTestTypePair&& other) noexcept
27 : value(other.value), moved_to(true) {
28 other.moved_from = true;
29 other.value = 0;
30 }
31
32 // Copy assignment
33 MoveTestTypePair& operator=(const MoveTestTypePair& other) {
34 value = other.value;
35 return *this;
36 }
37
38 // Move assignment
39 MoveTestTypePair& operator=(MoveTestTypePair&& other) noexcept {
40 value = other.value;
41 moved_to = true;
42 other.moved_from = true;
43 other.value = 0;
44 return *this;
45 }
46
47 bool operator==(const MoveTestTypePair& other) const {
48 return value == other.value;
49 }
50
51 bool operator<(const MoveTestTypePair& other) const {
52 return value < other.value;
53 }
54};
55
56} // anonymous namespace
57

Callers 1

FL_TEST_FILEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected