Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the best alternative library to gettimeofday() in C++?

Is there a more Object Oriented alternative to using gettimeofday() in C++ on linux? I like for instance to be able to write code similar to this:

DateTime now = new DateTime;
DateTime duration = new DateTime(2300, DateTime.MILLISECONDS)
DateTime deadline = now + duration;

while(now < deadline){
    DoSomething();
    delete now;
    now = new DateTime()
}

The target is an embedded linux system and there are no Boost libraries, but maybe there is something that is easy to port (something implemented with header files only for example).

like image 929
mikelong Avatar asked Feb 27 '23 15:02

mikelong


1 Answers

There is no object-oriented interface for dealing with time and intervals that's part of the standard C++ library.

You might want to look at Boost.Date_Time though. Boost is so useful and well written that its practically a part of the standard C++ library.

like image 175
Omnifarious Avatar answered Mar 27 '23 15:03

Omnifarious