This page is a snapshot from the LWG issues list, see the Library Active Issues List for more information and the meaning of Resolved status.

1327. templates defined in <cmath> replacing C macros with the same name

Section: 28.7 [c.math] Status: Resolved Submitter: Michael Wong Opened: 2010-03-07 Last modified: 2016-01-28

Priority: Not Prioritized

View all other issues in [c.math].

View all issues with Resolved status.

Discussion:

In 28.7 [c.math]p12 The templates defined in <cmath> replace the C99 macros with the same names. The templates have the following declarations:

namespace std {
template <class T> bool signbit(T x);
template <class T> int fpclassify(T x);
template <class T> bool isfinite(T x);
template <class T> bool isinf(T x);
template <class T> bool isnan(T x);
template <class T> bool isnormal(T x);
template <class T> bool isgreater(T x, T y);
template <class T> bool isgreaterequal(T x, T y);
template <class T> bool isless(T x, T y);
template <class T> bool islessequal(T x, T y);
template <class T> bool islessgreater(T x, T y);
template <class T> bool isunordered(T x, T y);
}

and p13:

13 The templates behave the same as the C99 macros with corresponding names defined in C99 7.12.3, Classification macros, and C99 7.12.14, Comparison macros in the C standard.

The C Std versions look like this:

7.12.14.1/p1:

Synopsis

1 #include <math.h>

int isgreaterequal(real-floating x, real-floating y);

which is not necessarily the same types as is required by C++ since the two parameters may be different. Would it not be better if it were truly aligned with C?

[ 2010 Pittsburgh: Bill to ask WG-14 if heterogeneous support for the two-parameter macros is intended. ]

[ 2010-09-13 Daniel comments: ]

I recommend to resolve this issue as NAD Editorial because the accepted resolution for NB comment US-136 by motion 27 does address this.

[ 2010-09-14 Bill comments: ]

Motion 27 directly addresses LWG 1327 and solves the problem presented there. Moreover, the solution has been aired before WG14 with no dissent. These functions now behave the same for mixed-mode calls in both C and C++

Proposed resolution:

Apply proposed resolution for US-136