Implement std::any
What this preview is
Implement std::any is a cracked quant coding problem on language knowledge in Cpp, asked at Quant.
- Difficulty
- Cracked
- Topic
- Language Knowledge
- Discipline
- Quant development
- Language
- Cpp
Implementing type-erased storage with small-object optimization
This hard C++ coding problem tests whether you can build a type-safe, memory-efficient container that holds objects of arbitrary type. It is representative of systems-level interviews at quantitative trading firms, where understanding memory layout, allocation strategy, and C++ metaprogramming all matter.
The core challenge is to balance two competing concerns: storing small types (like integers) directly on the stack to avoid allocation overhead, while delegating larger types to the heap. You must also implement runtime type checking so that retrieving a value as the wrong type triggers an exception, and ensure cleanup happens automatically when the container is destroyed. The strict size budget forces you to think carefully about your data-structure representation.
- Type erasure and runtime type information
- Small-object optimization (SOO) trade-offs
- Memory layout and alignment in C++
- RAII and resource cleanup
- Function pointers or virtual dispatch for type-agnostic operations
Unlock full access to getcracked
Join to unlock this problem, detailed solutions, and our complete library of quant finance interview prep.