public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/45866] New: std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members.
@ 2010-10-02 12:08 kalven at gmail dot com
  2010-10-02 12:40 ` [Bug libstdc++/45866] [C++0x] " redi at gcc dot gnu.org
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: kalven at gmail dot com @ 2010-10-02 12:08 UTC (permalink / raw)
  To: gcc-bugs

http://gcc.gnu.org/bugzilla/show_bug.cgi?id=45866

           Summary: std::ratio_add, ratio_sub, ratio_multiply,
                    ratio_divide do not have num and den members.
           Product: gcc
           Version: 4.5.1
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned@gcc.gnu.org
        ReportedBy: kalven@gmail.com


The latest C++ draft (which I think is n3126) says this about ratio_add:

"The type ratio_add<R1, R2> shall be a synonym for ratio<T1, T2> where T1 has
the value R1::num * R2::den + R2::num * R1::den and T2 has the value R1::den *
R2::den."

The current implementation in libstdc++ is:

  template<typename _R1, typename _R2>
    struct ratio_add
    {
    private:
      static const intmax_t __gcd =
        __static_gcd<_R1::den, _R2::den>::value;

    public:
      typedef ratio<
        __safe_add<
          __safe_multiply<_R1::num, (_R2::den / __gcd)>::value,
          __safe_multiply<_R2::num, (_R1::den / __gcd)>::value>::value,
        __safe_multiply<_R1::den, (_R2::den / __gcd)>::value> type;
    };

Which places the result in a nested type. I interpret the wording of the
standard to mean that ratio_add<R1, R2> should have the static members num and
den.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2010-10-18 17:30 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-10-02 12:08 [Bug libstdc++/45866] New: std::ratio_add, ratio_sub, ratio_multiply, ratio_divide do not have num and den members kalven at gmail dot com
2010-10-02 12:40 ` [Bug libstdc++/45866] [C++0x] " redi at gcc dot gnu.org
2010-10-02 12:43 ` redi at gcc dot gnu.org
2010-10-18 16:35 ` paolo.carlini at oracle dot com
2010-10-18 16:36 ` paolo.carlini at oracle dot com
2010-10-18 17:28 ` paolo at gcc dot gnu.org
2010-10-18 17:30 ` paolo.carlini at oracle dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).