Skip to content

Commit 51fc4ab

Browse files
rwgkcopybara-github
authored andcommitted
native_proto_caster.h: Add *_with_smart_holder_support_enabled specializations.
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: 658867114
1 parent 84653a5 commit 51fc4ab

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

pybind11_protobuf/native_proto_caster.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,20 @@ struct type_caster<
9191
: public pybind11_protobuf::proto_caster<
9292
ProtoType, pybind11_protobuf::native_cast_impl> {};
9393

94+
#if defined(PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT)
95+
96+
template <typename ProtoType>
97+
struct copyable_holder_caster_shared_ptr_with_smart_holder_support_enabled<
98+
ProtoType, enable_if_t<std::is_base_of<::google::protobuf::Message, ProtoType>::value>>
99+
: std::false_type {};
100+
101+
template <typename ProtoType>
102+
struct move_only_holder_caster_unique_ptr_with_smart_holder_support_enabled<
103+
ProtoType, enable_if_t<std::is_base_of<::google::protobuf::Message, ProtoType>::value>>
104+
: std::false_type {};
105+
106+
#endif // PYBIND11_HAVE_INTERNALS_WITH_SMART_HOLDER_SUPPORT
107+
94108
// NOTE: If smart_holders becomes the default we will need to change this to
95109
// type_caster<std::unique_ptr<ProtoType, D>, ...
96110
// Until then using that form is ambiguous due to the existing specialization

0 commit comments

Comments
 (0)