Skip to content
Quantoros

When does std::uniqueptr make sense vs. std::sharedptr?

C++Level: AdvancedMemory & Resource Management

When does std::unique_ptr make sense vs. std::shared_ptr?

Hints
  • Identify types, object lifetimes and compile-time decisions.
  • Separate language guarantees from a particular compiler's behavior.

Answer

This answer is part of mentoring

Advanced questions come with a full breakdown and a mock interview with a working quant researcher. The first call is free.

Source and licence: C/C++ Interview Cheatsheet — Chang Ning Tsai · MIT

Related questions