File tree 1 file changed +7
-4
lines changed
1 file changed +7
-4
lines changed Original file line number Diff line number Diff line change @@ -468,17 +468,20 @@ template <typename T,
468
468
typename D,
469
469
typename std::enable_if<std::is_default_constructible<D>::value, int >::type = 0 >
470
470
inline std::unique_ptr<T, D> unique_with_deleter (T *raw_ptr, std::unique_ptr<D> &&deleter) {
471
- if (deleter ! = nullptr ) {
472
- return std::unique_ptr<T, D>(raw_ptr, std::move (*deleter) );
471
+ if (deleter = = nullptr ) {
472
+ return std::unique_ptr<T, D>(raw_ptr);
473
473
}
474
- return std::unique_ptr<T, D>(raw_ptr);
474
+ return std::unique_ptr<T, D>(raw_ptr, std::move (*deleter) );
475
475
}
476
476
477
477
template <typename T,
478
478
typename D,
479
479
typename std::enable_if<!std::is_default_constructible<D>::value, int >::type = 0 >
480
480
inline std::unique_ptr<T, D> unique_with_deleter (T *raw_ptr, std::unique_ptr<D> &&deleter) {
481
- assert (deleter != nullptr );
481
+ if (deleter == nullptr ) {
482
+ pybind11_fail (" smart_holder_type_casters: deleter is not default constructible and no"
483
+ " instance available to return." );
484
+ }
482
485
return std::unique_ptr<T, D>(raw_ptr, std::move (*deleter));
483
486
}
484
487
You can’t perform that action at this time.
0 commit comments