Skip to content

Commit 0a22829

Browse files
rwgkcopybara-github
authored andcommitted
enum_type_caster.h compatibility with https://github.com/google/pywrapcc
This change probes `PYBIND11_HAS_NATIVE_ENUM` which was introduced with google/pybind11clif#30040. PiperOrigin-RevId: 532615246
1 parent 6ecec62 commit 0a22829

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

pybind11_protobuf/enum_type_caster.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,15 @@ namespace detail {
9696
//
9797
constexpr bool pybind11_protobuf_enable_enum_type_caster(...) { return true; }
9898

99+
#if defined(PYBIND11_HAS_NATIVE_ENUM)
100+
template <typename EnumType>
101+
struct type_caster_enum_type_enabled<
102+
EnumType, std::enable_if_t<(::google::protobuf::is_proto_enum<EnumType>::value &&
103+
pybind11_protobuf_enable_enum_type_caster(
104+
static_cast<EnumType*>(nullptr)))>>
105+
: std::false_type {};
106+
#endif
107+
99108
// Specialization of pybind11::detail::type_caster<T> for types satisfying
100109
// ::google::protobuf::is_proto_enum.
101110
template <typename EnumType>

0 commit comments

Comments
 (0)