|
Boost : |
Subject: Re: [boost] [filesystem] Epoch of trivial_clock
From: Rob Stewart (robertstewart_at_[hidden])
Date: 2014-08-23 08:58:24
On August 22, 2014 2:11:41 PM EDT, "AgustÃn K-ballo Bergé" <kaballo86_at_[hidden]> wrote:
>On 22/08/2014 08:10 a.m., Bjorn Reese wrote:
>> The filesystem::trivial_clock type is implementation-defined [1].
>That
>> means that the epoch is also implementation-defined.
>>
>> How do we determine the epoch of trivial_clock?
>
>Given a clock `C`, a default constructed `C::time_point` (or any
>instantiation of `time_point` for the clock `C`) represents the epoch
>of
>the clock. That is, for such a `time_point`, `time_since_epoch()` will
>return a duration of 0.
>
>That is somewhat obvious, the epoch is the origin, and unlikely to help
>your use case.
>
>It seems to me that what you need instead is to map a `time_point` from
>one clock to another, one that has an epoch under your control. That
>time_point could be the epoch of a clock. That is roughly done with:
>
> tp2 = C2::now() + (tp1 - C1::now())
That would be unstable as there's a race between the two calls to now(). It would also be unduly costly. Instead, just account for the origin differences:
tp2 = tp1 + C2:: time_point()
- C1:: time_point();
___
Rob
(Sent from my portable computation engine)
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk