Boost logo

Boost :

From: Jason Kankiewicz (jkankiewicz_at_[hidden])
Date: 2005-04-13 10:21:38


greg_day, greg_month and greg_year all have implicit conversions to
unsigned short. Math, and operator<< should just "work" for all three of
them.

Why, then, do both greg_day and greg_month have explicit conversions to
unsigned short via the "as_number" method?

Methinks "as_number" exists for the benefit of those who desire greater
clarity in their code; they prefer explicit conversions to implicit ones
and typing "Value.as_number()" is more express and elegant than typing
"unsigned short(Value)" or "static_cast<unsigned short>(Value)".

In this light, the lack of an "as_number" method in greg_year is a
glaring omission.

Bart wrote:
> On Mon, 06 Dec 2004 12:59:01 -0500, Joel Reed wrote:
>
>
>>the class gregorian::greg_year in the date_time library is missing a method
>>implemented in greg_day and greg_month.
>>
>>the method is:
>>
>> unsigned short as_number() const {return value_;}
>>
>>i checked cvs, on 12/6/04, to confirm this is still an issue.
>>http://cvs.sourceforge.net/viewcvs.py/boost/boost/boost/date_time/gregorian/greg_year.hpp?rev=1.4&view=auto
>>
>>we have been very impressed with this library and wanted to report
>>this minor inconsistency as a small, small way to say thanks.
>>
>>jr
>
>
> greg_year shouldn't need an as_number function. It's a constrained
> unsigned short with a min of 1400 & a max of 10000.
>
> The as_number function was added to greg_month and greg_day to ease math
> operations. Since greg_year is a constrained value math simply "works", as
> does operator<<.
>
> Is there a specific reason why you'd like one added to greg_year?
>
> Thx,
> Bart
>
>
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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