Boost logo

Boost Users :

Subject: Re: [Boost-users] [chron] time_point convertible?
From: Michael Powell (mwpowellhtx_at_[hidden])
Date: 2014-01-16 08:13:47


On Thu, Jan 16, 2014 at 3:53 AM, Krzysztof Czainski <1czajnik_at_[hidden]> wrote:
> 2014/1/16 Bjorn Reese <breese_at_[hidden]>
>>
>> On 01/16/2014 06:51 AM, Oliver Kowalke wrote:
>>>
>>> are the time_point-types of the clock-types from boost.chrono
>>> convertible into each other?
>>>
>>> chrono::system_clock::time_point t = convert_fun(
>>> chrono::steady_clock::now() ) etc. ?
>>
>>
>> chrono::steady_clock::time_point t1 = chrono::steady_clock::now();
>> chrono::steady_clock::duration d1 = t1.time_since_epoch();
>> chrono::system_clock::duration d2 =
>> chrono::duration_cast<chrono::system_clock::duration>(d1);
>> chrono::system_clock::time_point t2(d2);
>
>
> Are you saying the epoch is the same for steady_clock and system_clock?
> "There is no fixed relationship between values returned by
> steady_clock::now() and wall-clock time." [1]

I'm not sure why you would want to. If clock-credibility is in
question, the best you can do is synchronize your system clock. Other
than that, steady_clock is what you want for high-precision timing.
Casual inspection of the Boost.Chrono code will tell you that. If it's
still a problem, you might have a problem with your platform,
hardware, etc.

> Regards,
> Kris
>
> [1]
> http://www.boost.org/doc/libs/1_55_0/doc/html/chrono/reference.html#chrono.reference.cpp0x.system_clocks_hpp.steady_clock
>
> _______________________________________________
> Boost-users mailing list
> Boost-users_at_[hidden]
> http://lists.boost.org/mailman/listinfo.cgi/boost-users


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net