I have such code:
std::unordered_map futOrders;
auto i = futOrders.find(orderId);
if (i == futOrders.end()) {
LimitOrd
You can perform an emplace
, and check the return value to know whether the item was inserted or not:
std::unordered_map futOrders;
auto i = futOrders.emplace(
std::piecewise_construct, std::tie(orderId), std::make_tuple());
if (i.second) {
LimitOrder& newOrder = i.first->second;
// work
} else {
LimitOrder& futOrder = i.first->second;
// another work
}