Skip to content

Commit 35469a2

Browse files
committed
Improve type safety of internals.registered_types_cpp
1 parent f713f5e commit 35469a2

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

include/pybind11/cast.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,15 +195,15 @@ inline detail::type_info *get_local_type_info(const std::type_index &tp) {
195195
auto &locals = registered_local_types_cpp();
196196
auto it = locals.find(tp);
197197
if (it != locals.end())
198-
return (detail::type_info *) it->second;
198+
return it->second;
199199
return nullptr;
200200
}
201201

202202
inline detail::type_info *get_global_type_info(const std::type_index &tp) {
203203
auto &types = get_internals().registered_types_cpp;
204204
auto it = types.find(tp);
205205
if (it != types.end())
206-
return (detail::type_info *) it->second;
206+
return it->second;
207207
return nullptr;
208208
}
209209

include/pybind11/detail/internals.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ struct overload_hash {
6565
/// Whenever binary incompatible changes are made to this structure,
6666
/// `PYBIND11_INTERNALS_VERSION` must be incremented.
6767
struct internals {
68-
type_map<void *> registered_types_cpp; // std::type_index -> type_info
68+
type_map<type_info *> registered_types_cpp; // std::type_index -> type_info
6969
std::unordered_map<PyTypeObject *, std::vector<type_info *>> registered_types_py; // PyTypeObject* -> base type_info(s)
7070
std::unordered_multimap<const void *, instance*> registered_instances; // void * -> instance*
7171
std::unordered_set<std::pair<const PyObject *, const char *>, overload_hash> inactive_overload_cache;
@@ -167,8 +167,8 @@ PYBIND11_NOINLINE inline internals &get_internals() {
167167
}
168168

169169
/// Works like `internals.registered_types_cpp`, but for module-local registered types:
170-
PYBIND11_NOINLINE inline type_map<void *> &registered_local_types_cpp() {
171-
static type_map<void *> locals{};
170+
PYBIND11_NOINLINE inline type_map<type_info *> &registered_local_types_cpp() {
171+
static type_map<type_info *> locals{};
172172
return locals;
173173
}
174174

0 commit comments

Comments
 (0)