About this question

Weak Pointer Cache

Medium · memory_optimization · Quant Developer interview question · c++, smart_pointers, memory_management, hash_table

In high-frequency trading systems, maintaining an efficient cache of market data snapshots is critical for performance and memory management. Utilizing weak pointers allows multiple components, such as pricing engines and risk monitors, to share snapshot instances without redundant allocations while ensuring automatic eviction when no active references remain. Task Implement a MarketDataCache class utilizing std::weak_ptr to manage shared Snapshot objects. The class must support the following m