AdvancedMultiple choice
What does returning a large std::vector by value cost in modern C++?
- AEssentially nothing: it is moved or elided entirely
- BA full copy of every element
- CA heap allocation per element
- DIt depends on whether the caller uses the result
The worked solution is in Premium
The answer, the full working and the one idea to take away – for this and all 1,322 questions in the bank. Answer it in practice and your working is marked, with a known mistake named when you make one.
Learn the method
C++ for trading: RAII, moves and what belongs on the hot path
Reported in interviews at
More systems and low latency questions
- Which of these is the most important thing to remove from a hot path?Applied
- On a typical 64-bit platform, what is sizeof of struct { char a; int32_t b; char c; }?Applied
- Why do low-latency C++ codebases avoid virtual function calls on the hot path?Applied
- What does std::move(x) do by itself?Applied
- A std::vector starts with capacity 1 and doubles whenever it is full.Applied
- Per-thread counters, part 2 of 3Applied