Title
std::complex should add missing C99 functions
Status
cd1
Section
[complex.value.ops]
Submitter
Daniel Krügler

Created on 2008-01-26.00:00:00 last changed 171 months ago

Messages

Date: 2011-04-27.21:19:46

Proposed resolution:

In [complex.syn] add just between the declaration of conj and fabs:

template<class T> complex<T> conj(const complex<T>&);
template<class T> complex<T> proj(const complex<T>&);
template<class T> complex<T> fabs(const complex<T>&);

In [complex.value.ops] just after p.6 (return clause of conj) add:

template<class T> complex<T> proj(const complex<T>& x);

Effects: Behaves the same as C99 function cproj, defined in subclause 7.3.9.4."

In [cmplx.over] p. 1, add one further entry proj to the overload list.

The following function templates shall have additional overloads:

arg           norm 
conj          polar proj
imag          real
Date: 2011-04-27.21:19:46

A comparision of the N2461 header <complex> synopsis ([complex.syn]) with the C99 standard (ISO 9899, 2nd edition and the two corrigenda) show some complex functions that are missing in C++. These are:

  1. 7.3.9.4: (required elements of the C99 library)
    The cproj functions
  2. 7.26.1: (optional elements of the C99 library)
    cerf    cerfc    cexp2
    cexpm1  clog10   clog1p
    clog2   clgamma  ctgamma
    

I propose that at least the required cproj overloads are provided as equivalent C++ functions. This addition is easy to do in one sentence (delegation to C99 function).

Please note also that the current entry polar in [cmplx.over] p. 1 should be removed from the mentioned overload list. It does not make sense to require that a function already expecting scalar arguments should cast these arguments into corresponding complex<T> arguments, which are not accepted by this function.

History
Date User Action Args
2010-10-21 18:28:33adminsetmessages: + msg3755
2008-01-26 00:00:00admincreate