Skip to content

Commit e9070b2

Browse files
committed
Add enable_if_t to workaround.
1 parent 62311eb commit e9070b2

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

include/pybind11/operators.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,13 @@ struct op_impl {};
8484
/// Operator implementation generator
8585
template <op_id id, op_type ot, typename L, typename R>
8686
struct op_ {
87+
#if defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ == 11) && (__CUDACC_VER_MINOR__ >= 4) \
88+
&& (__CUDACC_VER_MINOR__ <= 8)
89+
// Nvidia's NVCC is broken between 11.4.0 and 11.8.0
90+
// https://github.com/pybind/pybind11/issues/4193
91+
# define PYBIND11_USING_WORKAROUND_FOR_CUDA_11_4_THROUGH_8
92+
static constexpr bool op_enable_if_hook = true;
93+
#endif
8794
template <typename Class, typename... Extra>
8895
void execute(Class &cl, const Extra &...extra) const {
8996
using Base = typename Class::type;

include/pybind11/pybind11.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1578,17 +1578,14 @@ class class_ : public detail::generic_type {
15781578
return *this;
15791579
}
15801580

1581-
// Nvidia's NVCC is broken between 11.4.0 and 11.8.0
1582-
// https://github.com/pybind/pybind11/issues/4193
1583-
#if defined(__CUDACC__) && (__CUDACC_VER_MAJOR__ == 11) && (__CUDACC_VER_MINOR__ >= 4) \
1584-
&& (__CUDACC_VER_MINOR__ <= 8)
1585-
template <typename T, typename... Extra>
1581+
#if defined(PYBIND11_USING_WORKAROUND_FOR_CUDA_11_4_THROUGH_8)
1582+
template <typename T, typename... Extra, detail::enable_if_t<T::op_enable_if_hook, int> = 0>
15861583
class_ &def(const T &op, const Extra &...extra) {
15871584
op.execute(*this, extra...);
15881585
return *this;
15891586
}
15901587

1591-
template <typename T, typename... Extra>
1588+
template <typename T, typename... Extra, detail::enable_if_t<T::op_enable_if_hook, int> = 0>
15921589
class_ &def_cast(const T &op, const Extra &...extra) {
15931590
op.execute_cast(*this, extra...);
15941591
return *this;

0 commit comments

Comments
 (0)