Skip to content

Commit b2252d8

Browse files
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. Signed-off-by: Cary Phillips <cary@ilm.com>
1 parent c005e35 commit b2252d8

1 file changed

Lines changed: 48 additions & 172 deletions

File tree

0 commit comments

Comments
 (0)