Skip to content

Commit 046c7db

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. 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

File tree

.github/workflows/ci_workflow.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ jobs:
4747
os: ubuntu-latest
4848
build: ${{ matrix.build }}
4949
cmake: ${{ matrix.cmake || '3.15.7' }}
50-
cxx-standard: ${{ matrix.cxx-standard || '14' }}
50+
cxx-standard: ${{ matrix.cxx-standard || '17' }}
5151
cxx-compiler: ${{ matrix.cxx-compiler || 'g++' }}
5252
cc-compiler: ${{ matrix.cc-compiler || 'gcc' }}
5353
build-type: ${{ matrix.build-type || 'Release' }}
@@ -84,7 +84,7 @@ jobs:
8484
python: 'OFF'
8585
pybind11: 'OFF'
8686
cmake: 3.14.7
87-
cxx-standard: 14
87+
cxx-standard: 20
8888

8989
- build: 5
9090
label: custom namespace
@@ -108,7 +108,7 @@ jobs:
108108
# values.
109109
os: ${{ matrix.os || 'macos-14' }}
110110
build: ${{ matrix.build }}
111-
cxx-standard: ${{ matrix.cxx-standard || '14' }}
111+
cxx-standard: ${{ matrix.cxx-standard || '17' }}
112112
build-type: ${{ matrix.build-type || 'Release' }}
113113
python: ${{ matrix.python || 'ON' }}
114114
pybind11: ${{ matrix.pybind11 || 'ON' }}
@@ -142,7 +142,7 @@ jobs:
142142
BUILD_TESTING: 'OFF'
143143
python: 'OFF'
144144
pybind11: 'OFF'
145-
cxx-standard: 14
145+
cxx-standard: 20
146146

147147
- build: 5
148148
label: macos-13
@@ -164,7 +164,7 @@ jobs:
164164
# values.
165165
os: ${{ matrix.os || 'windows-2022' }}
166166
build: ${{ matrix.build }}
167-
cxx-standard: ${{ matrix.cxx-standard || '14' }}
167+
cxx-standard: ${{ matrix.cxx-standard || '17' }}
168168
build-type: ${{ matrix.build-type || 'Release' }}
169169
python: ${{ matrix.python || 'ON' }}
170170
pybind11: ${{ matrix.pybind11 || 'ON' }}
@@ -204,7 +204,7 @@ jobs:
204204
BUILD_TESTING: 'OFF'
205205
python: 'OFF'
206206
pybind11: 'OFF'
207-
cxx-standard: 14
207+
cxx-standard: 20
208208

209209
- build: 5
210210
label: vfx2023

0 commit comments

Comments
 (0)