Boost logo

Boost Users :

From: Jeff Garland (jeff_at_[hidden])
Date: 2008-05-18 15:03:35


Igor R. wrote:
> Hi,
>
> As far as I see, the time_period class does not support any subtraction
> operation. Is it possible to add it to the "wishlist"? It would be very
> useful addition for the further releases of the library.
> I mean the following operation:
>
> ----[123456789)----- -----period1
> -------[3456789abcdef)---period2
> ---[0123456789abc)------perod3
>
> period2 - period1:
> -----------------[abcdef)
>
> period3 - period1:
> ---[0)----------[abc)
>

I'll stay out of the more general period discussion for now. So if I
understand your request, the signature of operator- would look something like
this:

   std::pair<time_period. time_period>
   operator-(time_period p1, time_period p2);

Right? And I guess in the case of period2 - period1 one of the return values
would be a null interval? There's also another case where there's no
intersection which I would assume would return the original interval?

Looking at this I wouldn't have a problem adding it to the wishlist -- it
looks useful. I'm unlikely to use operator- because it's a little too cute --
I'd prefer another name like remove_intersection that makes the function clearer.

HTH,

Jeff


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