|
Boost Users : |
From: Igor R. (igor_rubinov_at_[hidden])
Date: 2008-05-19 04:00:37
> std::pair<time_period. time_period> operator-(time_period p1, time_period p2);> Right?
Yes, that's what I thought about.
> And I guess in the case of period2 - period1 one of the return values would be a null interval?
I believe, the second one?
> There's also another case where there's no intersection which I would assume would return the original interval?
Yes, it would be consistent with a math. set subtraction.
Besides, period1 - null_period == period1 (*)
> 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.
Actually, if this operation works just like any ordinary set subtraction does, then operator -() seems to be ok, doesn't it? But, anyway, the name doesn't matter :)
(*) It would be also very useful if the rest of operations could work correctly with null_period; eg., period1.span(null_period) == period1 /*certainly, must be commutative*/
This way the code that uses various operations with periods would be cleaner (no need for numerous for is_null() checks).
Besides, if the time_period does not have a default constructor that initializes it to be null, probably it worth defining at least null_period constant? Now it's quite not trivial to make such an initialization:
time_period period(time_period(ptime(boost::date_time::not_a_date_time), ptime(date_time::not_a_date_time)));
Thanks a lot,
Igor'.
_________________________________________________________________
News, entertainment and everything you care about at Live.com. Get it now!
http://www.live.com/getstarted.aspx
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