Skip to content

Commit

Permalink
native_proto_caster.h: Add *_with_smart_holder_support_enabled spec…
Browse files Browse the repository at this point in the history
…ializations.

The

* `copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled` and

* `move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled`

SFINAE helpers were introduced with pybind/pybind11#5257. They need to be specialized here (`std::false_type`) because native_proto_caster.h has its own specializations for

* `copyable_holder_caster<ProtoType, std::shared_ptr<ProtoType>>` and

* `move_only_holder_caster<ProtoType, std::unique_ptr<ProtoType>>`.

PiperOrigin-RevId: 658807442
  • Loading branch information
Ralf W. Grosse-Kunstleve authored and copybara-github committed Aug 2, 2024
1 parent 84653a5 commit ca57662
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pybind11_protobuf/native_proto_caster.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,20 @@ struct type_caster<
: public pybind11_protobuf::proto_caster<
ProtoType, pybind11_protobuf::native_cast_impl> {};

#if defined(PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT)

template <typename ProtoType>
struct copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled<
ProtoType, enable_if_t<std::is_base_of<::google::protobuf::Message, ProtoType>::value>>
: std::false_type {};

template <typename ProtoType>
struct move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled<
ProtoType, enable_if_t<std::is_base_of<::google::protobuf::Message, ProtoType>::value>>
: std::false_type {};

#endif // PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT

// NOTE: If smart_holders becomes the default we will need to change this to
// type_caster<std::unique_ptr<ProtoType, D>, ...
// Until then using that form is ambiguous due to the existing specialization
Expand Down

0 comments on commit ca57662

Please sign in to comment.