This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Re: [v3] c++0x std::ratio implementation


On Fri, Jul 4, 2008 at 1:40 PM, Paolo Carlini <paolo.carlini@oracle.com> wrote:
> Hi,
>
>> I should also mention that the restriction of the range is due
>> to > 20.3.1 paragraph 1: "the absolute value of the template arguments
>> N and D shall be representable by type intmax_t". Since
>> abs(INTMAX_MIN) == INTMAX_MAX + 1, a diagnostic is issued if N/D == INTMAX_MIN.
>
> Right. Now I studied carefully the specifications and indeed everything is easy ;)
>
> The below is going in. A few not completely trivial changes:
>
> 1- Added missing definitions of ratio<>::num and ratio<>::den.
> 2- Adjusted the computation of __c in __safe_multiply: 1ul was not safe for 32bit machines.
> 3- Adjusted the testcases: as do-run tests you cannot ifdef out the main completely ;)
>
> Thanks again,
> Paolo.
>

Attached is a patch that short-cuts ratio_less when denominators are
equal or signs differ. This prevents overflow in a few cases (test
case provided).

Also, I added some doxygen documentation to std::ratio class. However,
when I built the documentation (html) it didn't look like it was
picking up the header. Does something need modification for doxygen to
pick it up?

Chris

Attachment: Changelog_ratio_less.txt
Description: Text document

Attachment: ratio_less_patch.txt
Description: Text document


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]