Skip to content

Commit

Permalink
Add static_assert() following a suggestion by @iwanders under PR #5334
Browse files Browse the repository at this point in the history
  • Loading branch information
Ralf W. Grosse-Kunstleve committed Aug 25, 2024
1 parent 9adbb61 commit be3bafe
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/pybind11/detail/struct_smart_holder.h
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,9 @@ struct smart_holder {
std::string("smart_holder::extract_deleter() precondition failure (") + context
+ ").");
}
return std::unique_ptr<D>(new D(custom_deleter_ptr->deleter)); // D must be copyable.
static_assert(std::is_copy_constructible<D>::value,
"Required for compatibility with smart_holder functionality.");
return std::unique_ptr<D>(new D(custom_deleter_ptr->deleter));

This comment has been minimized.

Copy link
@iwanders

iwanders Aug 25, 2024

Contributor

Yes, I like this 👍

}
return nullptr;
}
Expand Down

0 comments on commit be3bafe

Please sign in to comment.