Skip to content

Commit 6fa0a2e

Browse files
committed
PYBIND11_HAVE_HOLDER_CASTER_WITH_SMART_HOLDER_SUPPORT
Introduce two helper types: * copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled * move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled
1 parent 092d236 commit 6fa0a2e

File tree

1 file changed

+17
-2
lines changed

1 file changed

+17
-2
lines changed

include/pybind11/cast.h

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -835,9 +835,18 @@ struct copyable_holder_caster : public type_caster_base<type> {
835835
holder_type holder;
836836
};
837837

838+
#define PYBIND11_HAVE_HOLDER_CASTER_WITH_SMART_HOLDER_SUPPORT
839+
840+
template <typename, typename SFINAE = void>
841+
struct copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled : std::true_type {};
842+
838843
// BAKEIN_WIP
839844
template <typename type>
840-
struct copyable_holder_caster<type, std::shared_ptr<type>> : public type_caster_base<type> {
845+
struct copyable_holder_caster<
846+
type,
847+
std::shared_ptr<type>,
848+
enable_if_t<copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled<type>::value>>
849+
: public type_caster_base<type> {
841850
public:
842851
using base = type_caster_base<type>;
843852
static_assert(std::is_base_of<base, type_caster<type>>::value,
@@ -983,9 +992,15 @@ struct move_only_holder_caster {
983992
static constexpr auto name = type_caster_base<type>::name;
984993
};
985994

995+
template <typename, typename SFINAE = void>
996+
struct move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled : std::true_type {};
997+
986998
// BAKEIN_WIP
987999
template <typename type, typename deleter>
988-
struct move_only_holder_caster<type, std::unique_ptr<type, deleter>>
1000+
struct move_only_holder_caster<
1001+
type,
1002+
std::unique_ptr<type, deleter>,
1003+
enable_if_t<move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled<type>::value>>
9891004
: public type_caster_base<type> {
9901005
public:
9911006
using base = type_caster_base<type>;

0 commit comments

Comments
 (0)