lundi 30 avril 2018

Get return type of a variable to avoid signed integer overflow

I currently have something like this

std::atomic<std::chrono::time_point<std::chrono::steady_clock>> _blah
auto test = std::chrono::steady_clock::now() - _blah.load() > std::chrono::seconds(5); 

Because of second statement I get signed integer overflow warning. How can I get the return type of

std::chrono::steady_clock::now()

and then cast

_blah.load()

to that type to get rid of the warning ?

Aucun commentaire:

Enregistrer un commentaire