Skip to content

Commit 932769b

Browse files
authored
Adding holder_caster typename SFINAE = void hooks to help work around the current lack of smart-pointer interoperability (#2833)
* Adding move_only_holder_caster `typename SFINAE = void` to enable external specializations. * Adding SFINAE hook also to copyable_holder_caster, for uniformity, with comment to explain the purpose.
1 parent 23c3edc commit 932769b

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

include/pybind11/cast.h

+9-2
Original file line numberDiff line numberDiff line change
@@ -1525,7 +1525,11 @@ struct holder_helper {
15251525
};
15261526

15271527
/// Type caster for holder types like std::shared_ptr, etc.
1528-
template <typename type, typename holder_type>
1528+
/// The SFINAE hook is provided to help work around the current lack of support
1529+
/// for smart-pointer interoperability. Please consider it an implementation
1530+
/// detail that may change in the future, as formal support for smart-pointer
1531+
/// interoperability is added into pybind11.
1532+
template <typename type, typename holder_type, typename SFINAE = void>
15291533
struct copyable_holder_caster : public type_caster_base<type> {
15301534
public:
15311535
using base = type_caster_base<type>;
@@ -1600,7 +1604,10 @@ struct copyable_holder_caster : public type_caster_base<type> {
16001604
template <typename T>
16011605
class type_caster<std::shared_ptr<T>> : public copyable_holder_caster<T, std::shared_ptr<T>> { };
16021606

1603-
template <typename type, typename holder_type>
1607+
/// Type caster for holder types like std::unique_ptr.
1608+
/// Please consider the SFINAE hook an implementation detail, as explained
1609+
/// in the comment for the copyable_holder_caster.
1610+
template <typename type, typename holder_type, typename SFINAE = void>
16041611
struct move_only_holder_caster {
16051612
static_assert(std::is_base_of<type_caster_base<type>, type_caster<type>>::value,
16061613
"Holder classes are only supported for custom types");

0 commit comments

Comments
 (0)