We've upgraded code our execution! All Python submissions are using version 3.14, up from 3.12. 80% of C++ submissions are being compiled with C++26 (up from C++23). Soon 100% will.

Logo

Implement make_unique

What this preview is

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

Difficulty
Medium
Topic
Language Knowledge
Discipline
Quant development
Language
Cpp

Implementing make_unique with perfect forwarding in C++

This is a medium-difficulty C++ coding problem that tests your understanding of perfect forwarding and smart-pointer semantics. It's a canonical interview question at quant firms and other performance-sensitive shops where candidates must demonstrate command of modern C++ idioms.

The core challenge is to write a template function that forwards constructor arguments to an object of type T, wrapping the result in a std::unique_ptr, while preserving the value category (lvalue or rvalue) of each argument. This is essential for respecting move semantics and avoiding unnecessary copies. Your solution will be validated against a test object that counts construction, copy, and move events, so correctness of forwarding directly impacts the output.

  • Universal references and reference collapsing
  • The std::forward utility and its role in perfect forwarding
  • Ownership semantics of std::unique_ptr
  • Template argument deduction with variadic parameter packs

Unlock full access to getcracked

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