diff options
author | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-17 18:14:41 +0200 |
---|---|---|
committer | Claudius "keldu" Holeksa <mail@keldu.de> | 2024-05-17 18:14:41 +0200 |
commit | 7479b39379bcf79dfa73a61643538832c2571c49 (patch) | |
tree | 115666ec7696d12df2a9449e18f1fc5d4cf76cb8 /modules/core | |
parent | 059dc4308ac731d2b3c324166d87b8d527b9d217 (diff) |
Trying to get rpc interaction with iface working
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()); + } }; } |