Open Arthur940621 opened 2 years ago
int HeapTimer::GetNextTick() { tick(); size_t res = -1; if(!heap_.empty()) { res = std::chrono::duration_cast<MS>(heap_.front().expires - Clock::now()).count(); if(res < 0) { res = 0; } } return res; }
无符号整形值赋值-1会溢出吧? 如果std::chrono::durationcast(heap.front().expires - Clock::now()).count()也为负数,也会溢出
是的
无符号整形值赋值-1会溢出吧? 如果std::chrono::durationcast(heap .front().expires - Clock::now()).count()也为负数,也会溢出