diff options
Diffstat (limited to 'modules/core')
-rw-r--r-- | modules/core/c++/id_map.hpp | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/modules/core/c++/id_map.hpp b/modules/core/c++/id_map.hpp index 6172840..e1c1b3f 100644 --- a/modules/core/c++/id_map.hpp +++ b/modules/core/c++/id_map.hpp @@ -139,5 +139,21 @@ public: ); return void_t{}; } + + error_or<T*> find(const id<T>& val){ + if(val.get_value() >= data_.size()){ + return make_error<err::not_found>("ID is too large"); + } + + /** + * This can be removed technically if we are not in a debug state? + */ + auto find_id = std::find(free_ids_.begin(), free_ids_.end(), val); + if(find_id != free_ids_.end()){ + return make_error<err::not_found>("ID value has already been freed"); + } + + return &data_.at(val.get_value()); + } }; } |