Boost logo

Boost :

From: David Abrahams (dave_at_[hidden])
Date: 2004-04-17 03:43:10


Rob Stewart <stewart_at_[hidden]> writes:

>> > of 2004? If so, I'd be happy to say
>> >
>> > date(d.month() + 2*months, d.day)
>> >
>> > That, too, calls out the fact that adding months to dates has a
>> > dubious meaning.
>
> That makes the result of the expression quite explicit. I can't
> see any problems with that approach. I'd expect an exception if
> the resulting month doesn't have the requested day. OTOH, if
> date's ctor were to take an extra argument, or if there was a
> date factory function supplying the different behavior, you could
> specify that you want clipping to the last day of the designated
> month:
>
> date(d.month() + 2 * months, d.day(), clip_to_eom)
> make_date_clipped_to_end_of_month(d.month() + 2 * months,
> d.day())

Yes.

-- 
Dave Abrahams
Boost Consulting
http://www.boost-consulting.com

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