Logo

Coding preview

Implement unique_ptr

What this preview is

About this preview

Implement unique_ptr is a easy quant coding problem on language knowledge in Cpp, asked at Quant.

Unlock full access to getcracked

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

Implementing a custom unique_ptr with ownership tracking

This is an easy C++ coding problem that tests your understanding of move semantics, resource ownership, and smart-pointer design patterns. It's the kind of foundational question quant firms ask to verify you can implement low-level abstractions correctly—essential for building robust trading systems and risk engines.

The problem requires you to build a single-ownership smart pointer from scratch, implementing the full suite of constructors and assignment operators, then adding custom utility methods. The key challenges are ensuring move semantics transfer ownership safely, deliberately throwing on copy attempts, and managing cleanup through a custom deleter. You'll also need to track ownership state and expose it via a utility method.

  • Move semantics (constructor and assignment) and safe "moved-from" state
  • Exception-throwing copy operations and their role in ownership models
  • RAII: resource acquisition and cleanup via constructor/destructor
  • Operator overloading (dereference, arrow, bool conversion)
  • Custom deleters and their invocation semantics