Title
<cmath> functions unfriendly to integral_constant arguments
Status
nad
Section
[c.math]
Submitter
Matheus Izvekov

Created on 2015-02-13.00:00:00 last changed 102 months ago

Messages

Date: 2015-11-04.16:49:21

Proposed resolution:

This wording is relative to N4296.

  1. Change [c.math] p11 b2 as indicated:

    -11- Moreover, there shall be additional overloads sufficient to ensure:

    1. […]

    2. Otherwise, if any arithmetic argument corresponding to a double parameter has type double or an integer typea type which is not floating-point, but which is implicitly convertible to double, then all arithmetic arguments corresponding to double parameters are effectively cast to double.

    3. […]

Date: 2015-11-04.16:49:21

[ 2015-10, Kona Saturday afternoon ]

STL: This should be NAD, NAD-future and NAD-go-away. Users can already solve this using Walter's call syntax.

VV: I don't personally have this problem, but the proposed resolution seems frightening to me.

VV: There's a related issue, 2294, and also 2192.

STL: 2086 is about user-defined types in <cmath>, fixed in C++14. The PR for 2474 wants to undo the fix.

Link to 2086 and NAD.

Date: 2015-02-13.00:00:00

Using numeric wrappers with <cmath> functions is currently troublesome. Code such as: "std::exp2(std::integral_constant<int, 5>{})" will fail to compile because of ambiguity.

Arguments which are implicitly convertible to an arithmetic type should be accepted whenever the latter would be accepted.

David Krauss pointed out that some issue may present itself with numeric libraries which provide <cmath> equivalents in their own namespace which are not more specialized than the ones provided in <cmath>. If the changes proposed are implemented, then cases where the user brings those into scope through ADL might become ambiguous.

It's hard to assess how much breakage this would cause in the wild, and how much work it would take to fix. Should this be determined to be a problem, it's possible to make the new behaviour optional, and disabled by default for all user-defined types.

History
Date User Action Args
2015-11-04 16:49:21adminsetmessages: + msg7607
2015-11-04 16:49:21adminsetstatus: new -> nad
2015-03-31 20:43:10adminsetmessages: + msg7289
2015-02-13 00:00:00admincreate