Leka
A low-latency C++20 price-time-priority limit order book and matching engine
Replay viewer
Loading...
Searching...
No Matches
order_id_generator.cpp
1// src/order/order_id_generator.cpp
2#include "lob/types/order_id_generator.hpp"
3
4#include <limits>
5#include <stdexcept>
6
7namespace lob {
8
9/** Advances the generator without allowing identifiers to wrap to zero. */
11 if (currentId == std::numeric_limits<std::uint64_t>::max()) {
12 throw std::overflow_error("Order ID space exhausted"); // throw an exception if the maximum value is reached
13 }
14
15 return OrderId{++currentId};
16}
17
18} // namespace lob
OrderId generate()
Returns the next valid order identifier or throws on exhaustion.
Type-safe identifier for an order; zero is reserved as invalid.
Definition order_id.hpp:10