Boost logo

Boost :

Subject: Re: [boost] [filesystem] Epoch of trivial_clock
From: Agustín K-ballo Bergé (kaballo86_at_[hidden])
Date: 2014-08-23 10:14:06


On 23/08/2014 10:54 a.m., Bjorn Reese wrote:
> On 08/23/2014 02:58 PM, Rob Stewart wrote:
>
>> 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();
>
> AFAIK you cannot do arithmetic operations between time_point from
> different clocks.

That's correct. We can still make that snippet work by moving things around:

   tp2 = (tp1 - C1::tp()) + C2::tp() // ok, duration + time_point

   tp2 = tp1.time_since_epoch() + C2::tp() // same thing

   C2::tp tp2{tp1.time_since_epoch()}; // assuming compatible durations

Which gives you a time point which is as far from the epoch of C2 as the
original time point was from C1. Which as far as I know, it's meaningless.

Regards,

-- 
Agustín K-ballo Bergé.-
http://talesofcpp.fusionfenix.com

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk