Boost logo

Boost :

From: Jeff Garland (jeff_at_[hidden])
Date: 2006-12-12 16:54:46


Eric Niebler wrote:
> Jeff Garland wrote:
>> Eric Niebler wrote:
>>> Jeff Garland wrote:
>>> Of
>>>> course, what I'm thinking is for the stock price rolling average example above
>>>> you might want to use gregorian::date or posix_time::ptime to represent point
>>>> of measurement of the stock price. I wasn't finding the requirements for the
>>>> offset_type...which is what I think would need to be replaced.
>>> Right, I should document the requirements on the offset_type. The code
>>> has been tested with offset_types of int and double. I think the right
>>> concept for offset_type is LessThanComparible.
>> Well, here's the thing. In date-time the 'duration_type' and the
>> 'point_in_time_type' are different. For example, with dates you have 'date'
>> as the 'point_in_time' which is conceptually dimensionless and the
>> duration_type 'day'. If you subtract 2 points in time you get a duration. So
>> it's possible there would need to be a different type in the mix to make
>> things work. Anyway, this will be a good experiment at some point. I'd do it
>> myself if I only had more time.... ;-)
>
>
> Ah. So the type of (offset - offset) is not the same as the type of
> offset.

Well, depends on what we mean by an offset. From a concept perspective in
date-time it goes something like this:

   TimePoint - Timepoint --> Duration
   TimePoint - Duration --> TimePoint
   Duration - Duration --> Duration

concretely realized this means:

    date - date --> days
    date - days --> date
    days - days --> days

Same for the time types only at a higher resolution.

> That's not a problem in theory, but certainly the code doesn't
> handle that situation right now.

Yep, that's kinda what I was seeing.

Jeff


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