About this question

Strongly Typed Order Side

Easy · architecture & logic · Quant Developer interview question · c++, low-latency, architecture, constexpr

In low-latency trading systems, type safety is critical to prevent the accidental mixing of order sides, prices, and quantities. Utilizing a strongly typed scoped enumeration for order sides enforces this safety, while a constexpr function allows the compiler to evaluate the opposite side at compile time to eliminate runtime overhead. Task Implement a scoped enumeration enum class OrderSide containing two values: Buy = 0 and Sell = 1. Then, write a constexpr function flipSide(OrderSide side) th