Modern C++ Features for HFT Interviews
"So, are you comfortable with C++17?" The interviewer asks. Do not say "I used auto once."
1. Move Semantics (C++11)
Why HFT cares: Avoid deep copies of expensive objects (like huge vectors of market data).std::move casts to an rvalue reference, allowing resources to be "stolen" rather than copied.
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
2. Smart Pointers (C++11)
Why HFT cares: Memory leaks kill lengthy trading days.std::unique_ptr has ZERO overhead compared to raw pointers (it's just a wrapper that calls delete in destructor).std::shared_ptr has overhead (atomic reference counting). Use sparingly in hot paths.
3. Constexpr (C++11/14)
Why HFT cares: Calculate everything at compile time so the runtime is instantaneous.
You can parse FIX message templates or build lookup tables entirely during compilation.
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
| 7 | |
| 8 | |
4. Structured Binding (C++17)
Clean syntax for returning multiple values (like Go or Python).
| 1 | |
| 2 | |
| 3 | |
| 4 | |
| 5 | |
| 6 | |
5. Concepts (C++20)
Why HFT cares: Better template error messages.
Instead of a 500-line template error, you get "T does not satisfy Addable".