Why code bellow has no problem with a2 but does not compile for z1?
#include // std::nextafter #include // std::numeric_limits int main () { constexpr float a1 {1.f}; constexpr float a2 {std::nextafter(a1, std::numeric_limits::max())}; constexpr float z0 {0.f}; constexpr float z1 {std::nextafter(z0, std::numeric_limits::max())}; return 0; } Compiled with GCC 13.2
In file included from :1: /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/cmath: In function 'int main()': :9:39: in 'constexpr' expansion of 'std::nextafter(((float)z0), std::numeric_limits::max())' /opt/compiler-explorer/gcc-13.2.0/include/c++/13.2.0/cmath
Note: Clang 14.0 and MSVC 19.38 have problems even with a2.
Источник: https://stackoverflow.com/questions/780 ... expression
Мобильная версия