@@ -222,7 +222,7 @@ class cpp_function : public function {
222
222
auto *rec = unique_rec.get ();
223
223
224
224
/* Store the capture object directly in the function record if there is enough space */
225
- if (sizeof (capture) <= sizeof (rec->data )) {
225
+ if PYBIND11_IF_CONSTEXPR (sizeof (capture) <= sizeof (rec->data )) {
226
226
/* Without these pragmas, GCC warns that there might not be
227
227
enough space to use the placement new operator. However, the
228
228
'if' statement above ensures that this is the case. */
@@ -240,7 +240,7 @@ class cpp_function : public function {
240
240
241
241
// UB without std::launder, but without breaking ABI and/or
242
242
// a significant refactoring it's "impossible" to solve.
243
- if (!std::is_trivially_destructible<capture>::value) {
243
+ if PYBIND11_IF_CONSTEXPR (!std::is_trivially_destructible<capture>::value) {
244
244
rec->free_data = [](function_record *r) {
245
245
auto data = PYBIND11_STD_LAUNDER ((capture *) &r->data );
246
246
(void ) data;
@@ -349,7 +349,7 @@ class cpp_function : public function {
349
349
using FunctionType = Return (*)(Args...);
350
350
constexpr bool is_function_ptr
351
351
= std::is_convertible<Func, FunctionType>::value && sizeof (capture) == sizeof (void *);
352
- if (is_function_ptr) {
352
+ if PYBIND11_IF_CONSTEXPR (is_function_ptr) {
353
353
rec->is_stateless = true ;
354
354
rec->data [1 ]
355
355
= const_cast <void *>(reinterpret_cast <const void *>(&typeid (FunctionType)));
@@ -1595,7 +1595,7 @@ class class_ : public detail::generic_type {
1595
1595
1596
1596
generic_type::initialize (record);
1597
1597
1598
- if (has_alias) {
1598
+ if PYBIND11_IF_CONSTEXPR (has_alias) {
1599
1599
auto &instances = record.module_local ? get_local_internals ().registered_types_cpp
1600
1600
: get_internals ().registered_types_cpp ;
1601
1601
instances[std::type_index (typeid (type_alias))]
0 commit comments