2693. constexpr for various std::complex arithmetic and value operators

Section: 29.5 [complex.numbers] Status: New Submitter: Oliver Rosten Opened: 2016-04-14 Last modified: 2017-02-02

Priority: 3

View other active issues in [complex.numbers].

View all other issues in [complex.numbers].

View all issues with New status.

Discussion:

This modification will allow complex-number arithmetic to be performed at compile time. From a mathematical standpoint, it is natural (and desirable) to treat complex numbers on the same footing as the reals. From a programming perspective, this change will broaden the scope in which std::complex can be used, allowing it to be smoothly incorporated into classes exploiting constexpr.

Suggested resolution:

The following functions in the std::complex namespace should be made constexpr:

  1. Section 29.5.5 [complex.member.ops]: The member (arithmetic) operators {+=, -=, /=, *=}

  2. Section 29.5.6 [complex.ops]: The arithmetic operators unary operators {+, -} and binary operators {+, -, /, *};

  3. Section 29.5.7 [complex.value.ops]: The 'value' operators abs, norm, and conj.

In terms of modification of the standard, all that is required is the insertion of the constexpr specifier in the relevant parts of:

  1. Section 29.5.1 [complex.syn] (the Header synopsis), together with the corresponding entries in sections 29.5.6 [complex.ops] and 29.5.7 [complex.value.ops].

  2. Sections 29.5.2 [complex], 29.5.3 [complex.special] (class template and specializations), together with the corresponding entries in section 29.5.5 [complex.member.ops].

[2016-05 Issues Telecon]

This kind of work (new feature) has been being done via papers rather than via the issues list.

Walter believes that he knows someone who would be willing to write such a paper.

Proposed resolution: