@@ -204,7 +204,7 @@ class cpp_function : public function {
204204 auto *rec = unique_rec.get ();
205205
206206 /* 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 )) {
208208 /* Without these pragmas, GCC warns that there might not be
209209 enough space to use the placement new operator. However, the
210210 'if' statement above ensures that this is the case. */
@@ -222,7 +222,7 @@ class cpp_function : public function {
222222
223223 // UB without std::launder, but without breaking ABI and/or
224224 // 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) {
226226 rec->free_data = [](function_record *r) {
227227 auto data = PYBIND11_STD_LAUNDER ((capture *) &r->data );
228228 (void ) data;
@@ -331,7 +331,7 @@ class cpp_function : public function {
331331 using FunctionType = Return (*)(Args...);
332332 constexpr bool is_function_ptr
333333 = std::is_convertible<Func, FunctionType>::value && sizeof (capture) == sizeof (void *);
334- if (is_function_ptr) {
334+ if PYBIND11_IF_CONSTEXPR (is_function_ptr) {
335335 rec->is_stateless = true ;
336336 rec->data [1 ]
337337 = const_cast <void *>(reinterpret_cast <const void *>(&typeid (FunctionType)));
@@ -1605,7 +1605,7 @@ class class_ : public detail::generic_type {
16051605
16061606 generic_type::initialize (record);
16071607
1608- if (has_alias) {
1608+ if PYBIND11_IF_CONSTEXPR (has_alias) {
16091609 with_internals ([&](internals &internals) {
16101610 auto &instances = record.module_local ? get_local_internals ().registered_types_cpp
16111611 : internals.registered_types_cpp ;
0 commit comments