Commit 046c7db
committed
Replace =delete with SFINAE for invalid Vec integer methods
The Vec2, Vec3, and Vec4 classes declare methods length(),
normalize(), normalizeExc(), normalizeNonNull(), normalized(),
normalizedExc(), and normalizedNonNull(), which are invalid for
integer types.
The pre-existing declarations remove the integer instantiations via
`=delete`:
template <>
IMATH_HOSTDEVICE short Vec2<short>::length () const IMATH_NOEXCEPT = delete;
but this appears to not work with Clang20 (at least on msys2, as
reported in
AcademySoftwareFoundation/openexr#2101). The
template appears to get instantiated _before_ the `=delete`, which
causes an error. I tried moving the `=delete` to _just_ after the
class declaration, but that doesn't appear to resolve the problem.
This change replaces the `=delete` with SFINAE (Substitution Failure is Not an Error):
template <typename U=T, typename = std::enable_if_t<std::is_floating_point_v<U>>>
IMATH_HOSTDEVICE T length () const IMATH_NOEXCEPT;
With this form, the declaration is excluded entirely if the condition
fails (i.e. if T is not a floating-point type). Unlike `=delete`, which
makes the function ill-formed if called, SFINAE makes the function
invisible to the compiler when the condition is not satisfied.
Note that this requires C++17. Imath has previously only required
C++14.
Signed-off-by: Cary Phillips <cary@ilm.com>1 parent c005e35 commit 046c7db
2 files changed
Lines changed: 54 additions & 178 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
47 | 47 | | |
48 | 48 | | |
49 | 49 | | |
50 | | - | |
| 50 | + | |
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| |||
84 | 84 | | |
85 | 85 | | |
86 | 86 | | |
87 | | - | |
| 87 | + | |
88 | 88 | | |
89 | 89 | | |
90 | 90 | | |
| |||
108 | 108 | | |
109 | 109 | | |
110 | 110 | | |
111 | | - | |
| 111 | + | |
112 | 112 | | |
113 | 113 | | |
114 | 114 | | |
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
145 | | - | |
| 145 | + | |
146 | 146 | | |
147 | 147 | | |
148 | 148 | | |
| |||
164 | 164 | | |
165 | 165 | | |
166 | 166 | | |
167 | | - | |
| 167 | + | |
168 | 168 | | |
169 | 169 | | |
170 | 170 | | |
| |||
204 | 204 | | |
205 | 205 | | |
206 | 206 | | |
207 | | - | |
| 207 | + | |
208 | 208 | | |
209 | 209 | | |
210 | 210 | | |
| |||
0 commit comments