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

Class MoveTestTypeMove

tests/fl/stl/move.cpp:41–81  ·  view source on GitHub ↗

Helper class to test move semantics

Source from the content-addressed store, hash-verified

39
40// Helper class to test move semantics
41struct MoveTestTypeMove {
42 int value;
43 bool moved_from;
44 bool moved_to;
45
46 MoveTestTypeMove() : value(0), moved_from(false), moved_to(false) {}
47 explicit MoveTestTypeMove(int v) : value(v), moved_from(false), moved_to(false) {}
48
49 // Copy constructor
50 MoveTestTypeMove(const MoveTestTypeMove& other)
51 : value(other.value), moved_from(false), moved_to(false) {}
52
53 // Move constructor
54 MoveTestTypeMove(MoveTestTypeMove&& other)
55 : value(other.value), moved_from(false), moved_to(true) {
56 other.moved_from = true;
57 other.value = 0;
58 }
59
60 // Copy assignment
61 MoveTestTypeMove& operator=(const MoveTestTypeMove& other) {
62 if (this != &other) {
63 value = other.value;
64 moved_from = false;
65 moved_to = false;
66 }
67 return *this;
68 }
69
70 // Move assignment
71 MoveTestTypeMove& operator=(MoveTestTypeMove&& other) {
72 if (this != &other) {
73 value = other.value;
74 moved_from = false;
75 moved_to = true;
76 other.moved_from = true;
77 other.value = 0;
78 }
79 return *this;
80 }
81};
82
83} // anonymous namespace
84

Callers 1

FL_TEST_FILEFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected