What this C++ shared-pointer design question tests
This is a medium-difficulty question on the practical trade-offs between different ways to construct a shared pointer in C++. It assesses whether you understand not just the syntax of std::make_shared versus raw new, but the performance and safety implications that matter in production systems.
Candidates should be familiar with the real reasons engineers prefer std::make_shared: memory layout efficiency, exception safety during construction, and atomic control-block allocation. The question format—identifying what is not a valid reason—requires you to distinguish between genuine technical benefits and misconceptions that sometimes circulate in code reviews and documentation.
- Single heap allocation vs. separate allocations for object and control block
- Exception safety during temporary object construction
- Reference-count performance and memory layout
- When raw
new is necessary or unavoidable