mirror of
https://github.com/BlackMATov/meta.hpp.git
synced 2025-12-13 19:18:01 +07:00
fix some potential problem in the type_registry::for_each_type function
This commit is contained in:
@@ -41,7 +41,7 @@ namespace meta_hpp::detail
|
||||
void for_each_scope(F&& f) const {
|
||||
const locker lock;
|
||||
|
||||
for ( auto&& [name, scope] : scopes_ ) {
|
||||
for ( auto&& [_, scope] : scopes_ ) {
|
||||
std::invoke(f, scope);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,8 +41,10 @@ namespace meta_hpp::detail
|
||||
void for_each_type(F&& f) const {
|
||||
const locker lock;
|
||||
|
||||
for ( const any_type& type : types_ ) {
|
||||
std::invoke(f, type);
|
||||
// we use an index based for loop to avoid the iterator invalidation issues
|
||||
// that can happen when adding a new type inside the loop
|
||||
for ( std::size_t i{}; i < types_.size(); ++i ) {
|
||||
std::invoke(f, types_[i]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user