Skip to content

Commit 99ff13e

Browse files
committed
Iterate over values, not references
We're just iterating over pointer values; it simpler just to iterate over pointer values rather than const pointer references.
1 parent 652335f commit 99ff13e

File tree

1 file changed

+3
-6
lines changed

1 file changed

+3
-6
lines changed

include/pybind11/cast.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,9 @@ struct all_type_info {
139139
iterator(vec_iter &&it, detail::type_info *single_base)
140140
: all_it{std::move(it)}, single{single_base} {}
141141

142-
using value_type = detail::type_info *;
143-
using reference = const value_type &;
144-
145142
bool operator==(const iterator &it) { return single ? single == it.single : all_it == it.all_it; }
146143
bool operator!=(const iterator &it) { return !(*this == it); }
147-
reference operator*() { return single ? single : *all_it; }
144+
detail::type_info *operator*() { return single ? single : *all_it; }
148145
iterator &operator ++() {
149146
if (single) single = nullptr;
150147
else ++all_it;
@@ -382,7 +379,7 @@ PYBIND11_NOINLINE inline handle get_object_handle(const void *ptr, const detail:
382379
auto &instances = get_internals().registered_instances;
383380
auto range = instances.equal_range(ptr);
384381
for (auto it = range.first; it != range.second; ++it) {
385-
for (const auto &instance_type : detail::all_type_info(Py_TYPE(it->second))) {
382+
for (auto instance_type : detail::all_type_info(Py_TYPE(it->second))) {
386383
if (instance_type && instance_type == type)
387384
return handle((PyObject *) it->second);
388385
}
@@ -485,7 +482,7 @@ class type_caster_generic {
485482

486483
auto it_instances = internals.registered_instances.equal_range(src);
487484
for (auto it_i = it_instances.first; it_i != it_instances.second; ++it_i) {
488-
for (auto &instance_type : detail::all_type_info(Py_TYPE(it_i->second))) {
485+
for (auto instance_type : detail::all_type_info(Py_TYPE(it_i->second))) {
489486
if (instance_type && instance_type == tinfo)
490487
return handle((PyObject *) it_i->second).inc_ref();
491488
}

0 commit comments

Comments
 (0)