In embedded firmware systems, sensor data buffers are frequently passed between tasks, queues, or ISR-to-thread boundaries. These buffers often own dynamically allocated memory, and copying them can be expensive on memory- and performance-constrained hardware.
To reduce overhead, such systems rely on move semantics, allowing ownership of resources to be transferred instead of copied.
You are given a SensorBuffer class that owns a dynamically allocated byte buffer. Your task is to implement a move constructor that transfers ownership of the buffer safely and efficiently.
After implementing the move constructor:
Program Flow:
NN bytesA with size NB from AABExpected Behavior After Move:
A prints: No dataB prints the original byte sequenceExample Input:
5
10 20 30 40 50 Example Output:
No data
10 20 30 40 50 Constraints:
1 ≤ N ≤ 100new[]If the buffer is empty, output must be exactly:
No data
Input
1 42
Expected Output
No data 42