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

Function FL_TEST_FILE

tests/fl/stl/allocator_move.cpp:21–387  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

19#include "fl/stl/int.h"
20
21FL_TEST_FILE(FL_FILEPATH) {
22
23namespace {
24
25// Tracking allocator that records copy and move operations
26template <typename T>
27class TrackingAllocator {
28public:
29 // Type definitions required by STL
30 using value_type = T;
31 using pointer = T*;
32 using const_pointer = const T*;
33 using reference = T&;
34 using const_reference = const T&;
35 using size_type = fl::size;
36 using difference_type = fl::ptrdiff_t;
37
38 // Rebind allocator to type U
39 template <typename U>
40 struct rebind {
41 using other = TrackingAllocator<U>;
42 };
43
44 // Tracking state (shared pointer to allow copy/move tracking)
45 struct Stats {
46 int copy_constructs = 0;
47 int move_constructs = 0;
48 int copy_assigns = 0;
49 int move_assigns = 0;
50 int allocations = 0;
51 int deallocations = 0;
52
53 void reset() {
54 copy_constructs = 0;
55 move_constructs = 0;
56 copy_assigns = 0;
57 move_assigns = 0;
58 allocations = 0;
59 deallocations = 0;
60 }
61 };
62
63 Stats* stats; // Non-owning pointer to shared stats
64
65 // Default constructor
66 TrackingAllocator() noexcept : stats(nullptr) {}
67
68 // Constructor with stats tracking
69 explicit TrackingAllocator(Stats* s) noexcept : stats(s) {}
70
71 // Copy constructor
72 TrackingAllocator(const TrackingAllocator& other) noexcept : stats(other.stats) {
73 if (stats) {
74 stats->copy_constructs++;
75 }
76 }
77
78 // Move constructor

Callers

nothing calls this directly

Calls 6

resetMethod · 0.45
push_backMethod · 0.45
sizeMethod · 0.45
emptyMethod · 0.45
insertMethod · 0.45
hasMethod · 0.45

Tested by

no test coverage detected