[all-commits] [llvm/llvm-project] 866bec: [libc++][math] Provide overloads for cv-unqualifie...
Robin Caloudis via All-commits
all-commits at lists.llvm.org
Wed Aug 28 01:35:08 PDT 2024
Branch: refs/heads/main
Home: https://github.com/llvm/llvm-project
Commit: 866bec7d3ff8803b68e9972939c1a76ccf5fdc62
https://github.com/llvm/llvm-project/commit/866bec7d3ff8803b68e9972939c1a76ccf5fdc62
Author: Robin Caloudis <robin.caloudis at gmx.de>
Date: 2024-08-28 (Wed, 28 Aug 2024)
Changed paths:
M libcxx/include/__math/traits.h
M libcxx/test/std/numerics/c.math/isnormal.pass.cpp
Log Message:
-----------
[libc++][math] Provide overloads for cv-unqualified floating point types for `std::isnormal` (#104773)
## Why
Currently, the following does not work when compiled with clang:
```c++
#include <cmath>
struct ConvertibleToFloat {
operator float();
};
bool test(ConvertibleToFloat x) {
return std::isnormal(x);
}
```
See https://godbolt.org/z/5bos8v67T for differences with respect to
msvc, gcc or icx. It fails for `float`, `double` and `long double` (all
cv-unqualified floating-point types).
## What
Test and provide overloads as expected by the ISO C++ standard. The
classification/comparison function `isnormal` is defined since C++11
until C++23 as
```c++
bool isnormal( float num );
bool isnormal( double num );
bool isnormal( long double num );
```
and since C++23 as
```c++
constexpr bool isnormal( /* floating-point-type */ num );
```
for which "the library provides overloads for all cv-unqualified
floating-point types as the type of the parameter num". See §28.7.1/1 in
the [ISO C++
standard](https://www.open-std.org/jtc1/sc22/wg21/docs/papers/2023/n4950.pdf)
or check
[cppreference](https://en.cppreference.com/w/cpp/numeric/math/isnormal).
To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications
More information about the All-commits
mailing list