Skip to content

Commit be3bafe

Browse files
committed
Add static_assert() following a suggestion by @iwanders under PR #5334
1 parent 9adbb61 commit be3bafe

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

include/pybind11/detail/struct_smart_holder.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ struct smart_holder {
242242
std::string("smart_holder::extract_deleter() precondition failure (") + context
243243
+ ").");
244244
}
245-
return std::unique_ptr<D>(new D(custom_deleter_ptr->deleter)); // D must be copyable.
245+
static_assert(std::is_copy_constructible<D>::value,
246+
"Required for compatibility with smart_holder functionality.");
247+
return std::unique_ptr<D>(new D(custom_deleter_ptr->deleter));
246248
}
247249
return nullptr;
248250
}

0 commit comments

Comments
 (0)