@@ -204,7 +204,7 @@ class cpp_function : public function {
204
204
auto *rec = unique_rec.get ();
205
205
206
206
/* Store the capture object directly in the function record if there is enough space */
207
- if (sizeof (capture) <= sizeof (rec->data )) {
207
+ if PYBIND11_IF_CONSTEXPR (sizeof (capture) <= sizeof (rec->data )) {
208
208
/* Without these pragmas, GCC warns that there might not be
209
209
enough space to use the placement new operator. However, the
210
210
'if' statement above ensures that this is the case. */
@@ -222,7 +222,7 @@ class cpp_function : public function {
222
222
223
223
// UB without std::launder, but without breaking ABI and/or
224
224
// a significant refactoring it's "impossible" to solve.
225
- if (!std::is_trivially_destructible<capture>::value) {
225
+ if PYBIND11_IF_CONSTEXPR (!std::is_trivially_destructible<capture>::value) {
226
226
rec->free_data = [](function_record *r) {
227
227
auto data = PYBIND11_STD_LAUNDER ((capture *) &r->data );
228
228
(void ) data;
@@ -331,7 +331,7 @@ class cpp_function : public function {
331
331
using FunctionType = Return (*)(Args...);
332
332
constexpr bool is_function_ptr
333
333
= std::is_convertible<Func, FunctionType>::value && sizeof (capture) == sizeof (void *);
334
- if (is_function_ptr) {
334
+ if PYBIND11_IF_CONSTEXPR (is_function_ptr) {
335
335
rec->is_stateless = true ;
336
336
rec->data [1 ]
337
337
= const_cast <void *>(reinterpret_cast <const void *>(&typeid (FunctionType)));
@@ -1605,7 +1605,7 @@ class class_ : public detail::generic_type {
1605
1605
1606
1606
generic_type::initialize (record);
1607
1607
1608
- if (has_alias) {
1608
+ if PYBIND11_IF_CONSTEXPR (has_alias) {
1609
1609
with_internals ([&](internals &internals) {
1610
1610
auto &instances = record.module_local ? get_local_internals ().registered_types_cpp
1611
1611
: internals.registered_types_cpp ;
0 commit comments