Skip to content

Commit 5ed0abc

Browse files
committed
vptr_map: bugfix: vptr_map accumulates with multiple initialize()
1 parent 51394a8 commit 5ed0abc

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

include/boost/openmethod/policies/vptr_map.hpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,19 +42,23 @@ class vptr_map : public vptr {
4242
//! @ref IdsToVptr objects.
4343
//! @param first The beginning of the range.
4444
//! @param last The end of the range.
45-
template<class ForwardIterator>
45+
template<class ForwardIterator, class... Options>
4646
static void initialize(ForwardIterator first, ForwardIterator last) {
47+
decltype(vptrs) new_vptrs;
48+
4749
for (auto iter = first; iter != last; ++iter) {
4850
for (auto type_iter = iter->type_id_begin();
4951
type_iter != iter->type_id_end(); ++type_iter) {
5052

5153
if constexpr (Registry::has_indirect_vptr) {
52-
vptrs.emplace(*type_iter, &iter->vptr());
54+
new_vptrs.emplace(*type_iter, &iter->vptr());
5355
} else {
54-
vptrs.emplace(*type_iter, iter->vptr());
56+
new_vptrs.emplace(*type_iter, iter->vptr());
5557
}
5658
}
5759
}
60+
61+
vptrs.swap(new_vptrs);
5862
}
5963

6064
//! Returns a reference to a v-table pointer for an object.

0 commit comments

Comments
 (0)