Question.1
A Buffer class manages a 1 KB heap allocation. A developer compares the following operations:
Buffer
Buffer a(1024); Buffer b = a; // Copy Buffer c = std::move(a); // Move
What operations does each perform?
Select Answer
Copy: allocates 1024 bytes + memcpy. Move: copies one pointer (4 bytes) + sets source to nullptr -- near zero cost
memcpy
nullptr
Both allocate nMove allocates new memory; copy reuses the oldew memory and copy 1024 bytes
Move allocates new memory; copy reuses the old
Both just copy the pointer -- no difference