cpprefjp / site

cpprefjpサイトのMarkdownソース
https://cpprefjp.github.io/
375 stars 155 forks source link

<cmath>のIntegralオーバーロードは削除された? #1127

Closed faithandbrave closed 1 year ago

faithandbrave commented 1 year ago

<cmath>constexpr対応を進めているのですが、Integralのオーバーロードはもしかして削除されてますかね…。 どうなっているのかと経緯を調べます…。

faithandbrave commented 1 year ago

C++14の規格 (N3936) では、以下の文章がそれにあたるかと思います。

Moreover, there shall be additional overloads sufficient to ensure:

  1. If any arithmetic argument corresponding to a double parameter has type long double, then all arithmetic arguments corresponding to double parameters are effectively cast to long double.
  2. Otherwise, if any arithmetic argument corresponding to a double parameter has type double or an integer type, then all arithmetic arguments corresponding to double parameters are effectively cast to double.
  3. Otherwise, all arithmetic arguments corresponding to double parameters have type float.

これの2. で、整数型はdoubleにキャストされる、とある部分。

faithandbrave commented 1 year ago

C++23でもありました。。。 拡張浮動小数点数型も考慮した文章になってるだけでした。

For each function with at least one parameter of type floating-point-type other than abs, the implementationalso provides additional overloads sufficient to ensure that, if every argument corresponding to a floating-pointtypeparameter has arithmetic type, then every such argument is effectively cast to the floating-point type withthe greatest floating-point conversion rank and greatest floating-point conversion subrank among the types of all such arguments, where arguments of integer type are considered to have the same floating-point conversionrank as double. If no such floating-point type with the greatest rank and subrank exists, then overloadresolution does not result in a usable candidate (12.2.1) from the overloads provided by the implementation.