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

Class MoveTrackItem

tests/misc/containers.cpp:614–650  ·  view source on GitHub ↗

Move-tracking item that allows copies but tracks them. Unlike TestItem (which deletes copies), this type lets us verify that containers USE move semantics even if they don't require move-only types.

Source from the content-addressed store, hash-verified

612// Unlike TestItem (which deletes copies), this type lets us verify that
613// containers USE move semantics even if they don't require move-only types.
614struct MoveTrackItem {
615 int value;
616 int move_count = 0;
617 int copy_count = 0;
618
619 MoveTrackItem() : value(0) {}
620 explicit MoveTrackItem(int v) : value(v) {}
621
622 MoveTrackItem(MoveTrackItem&& other) noexcept
623 : value(other.value), move_count(other.move_count + 1),
624 copy_count(other.copy_count) {
625 other.move_count++;
626 }
627
628 MoveTrackItem& operator=(MoveTrackItem&& other) noexcept {
629 value = other.value;
630 move_count = other.move_count + 1;
631 copy_count = other.copy_count;
632 other.move_count++;
633 return *this;
634 }
635
636 MoveTrackItem(const MoveTrackItem& other)
637 : value(other.value), move_count(other.move_count),
638 copy_count(other.copy_count + 1) {}
639
640 MoveTrackItem& operator=(const MoveTrackItem& other) {
641 value = other.value;
642 move_count = other.move_count;
643 copy_count = other.copy_count + 1;
644 return *this;
645 }
646
647 bool operator==(const MoveTrackItem& other) const {
648 return value == other.value;
649 }
650};
651
652// Move semantics verification for map containers.
653// Inserts values via move and verifies no copies occurred on the hot path.

Callers 1

test_map_move_semanticsFunction · 0.85

Calls

no outgoing calls

Tested by 1

test_map_move_semanticsFunction · 0.68