Logo

Question preview

Custom deleter magic?

What this preview is

About this preview

Custom deleter magic? is a easy quant interview question on language knowledge in Cpp.

Unlock full access to getcracked

Join to unlock this question, detailed solutions, and our complete library of quant finance interview prep.

What this C++ memory-layout question tests

This is an easy question on C++ object size and the Empty Base Optimization (EBO), a core language feature that affects how unique_ptr and other template classes pack their data members. It tests whether you can reason about the actual memory footprint of templated pointers with stateless deleters.

The question asks you to predict the size of a unique_ptr instance given a specific deleter implementation. To answer it correctly, you need to understand how the compiler lays out member variables, when it applies empty-class optimizations, and how the deleter—whether stateful or stateless—occupies (or doesn't occupy) space in the final object. This matters in performance-critical code where cache efficiency and memory density are measurable.

  • Empty Base Optimization and empty member optimization
  • Pointer size on 64-bit platforms
  • Stateless vs. stateful functors and lambda captures