@@ -464,29 +464,6 @@ struct shared_ptr_trampoline_self_life_support {
464
464
}
465
465
};
466
466
467
- template <typename D, bool >
468
- struct delete_assigner {
469
- static void assign (D &, bool , std::function<void (void *)> &, void (*)(void *) &) {
470
- // Situation where the deleter cannot be assigned from either del_fun or del_ptr.
471
- // This covers the default deleters and the like.
472
- }
473
- };
474
-
475
- template <typename D>
476
- struct delete_assigner <D, true > {
477
- static void assign (D &deleter,
478
- bool use_del_fun,
479
- std::function<void (void *)> &del_fun,
480
- void (*del_ptr)(void *) &) {
481
- // Situation where D is assignable from del_fun.
482
- if (use_del_fun) {
483
- deleter = std::move (del_fun);
484
- } else {
485
- deleter = del_ptr;
486
- }
487
- }
488
- };
489
-
490
467
template <typename T>
491
468
struct smart_holder_type_caster_load {
492
469
using holder_type = pybindit::memory::smart_holder;
@@ -639,18 +616,16 @@ struct smart_holder_type_caster_load {
639
616
" instance cannot safely be transferred to C++." );
640
617
}
641
618
642
- // Need to extract the deleter from the holder such that it can be passed back to the
643
- // unique pointer.
644
-
645
- // Temporary variable to store the extracted deleter in.
619
+ // Default constructed temporary variable to store the extracted deleter in.
646
620
D extracted_deleter;
647
621
648
- // In smart_holder_poc, the deleter is always stored in a guarded delete.
649
- // The guarded delete's std::function<void(void*)> actually points at the custom_deleter
650
- // type, so we can verify it is of the custom deleter type and finally extract its deleter.
651
622
auto *gd = std::get_deleter<pybindit::memory::guarded_delete>(holder ().vptr );
652
623
if (gd) {
653
624
if (gd->use_del_fun ) {
625
+ // In smart_holder_poc, a custom deleter is always stored in a guarded delete.
626
+ // The guarded delete's std::function<void(void*)> actually points at the
627
+ // custom_deleter type, so we can verify it is of the custom deleter type and
628
+ // finally extract its deleter.
654
629
using custom_deleter_D = pybindit::memory::custom_deleter<T, D>;
655
630
const auto &custom_deleter_ptr = gd->del_fun .template target <custom_deleter_D>();
656
631
if (!custom_deleter_ptr) {
@@ -661,14 +636,9 @@ struct smart_holder_type_caster_load {
661
636
// value we can extract the function.
662
637
extracted_deleter = std::move (custom_deleter_ptr->deleter );
663
638
} else {
664
- // The del_ptr attribute of the guarded deleter does not provide any type
665
- // information that can be used to confirm it is convertible to D. SFINEA here is
666
- // necessary to ensure that if D is not constructible from a void(void*) pointer,
667
- // it does not cause compilation failures. If this hits an non-convertible type at
668
- // compile time it throws.
669
- constexpr bool assignable = std::is_constructible<D, decltype (gd->del_fun )>::value;
670
- delete_assigner<D, assignable>::assign (
671
- extracted_deleter, gd->use_del_fun , gd->del_fun , gd->del_ptr );
639
+ // Not sure if anything needs to be done here. In general, if the del function is
640
+ // used a default destructor is used which should be accomodated by the type of the
641
+ // deleter used in the returned unique ptr.
672
642
}
673
643
}
674
644
0 commit comments