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

Paolo Carlini paolo.carlini@oracle.com
Fri Jul 4 17:42:00 GMT 2008


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.
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: CL_ratio.txt
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080704/80477ab6/attachment.txt>
-------------- next part --------------
An embedded and charset-unspecified text was scrubbed...
Name: patch_ratio.txt
URL: <http://gcc.gnu.org/pipermail/libstdc++/attachments/20080704/80477ab6/attachment-0001.txt>


More information about the Libstdc++ mailing list