From 7479b39379bcf79dfa73a61643538832c2571c49 Mon Sep 17 00:00:00 2001 From: "Claudius \"keldu\" Holeksa" Date: Fri, 17 May 2024 18:14:41 +0200 Subject: Trying to get rpc interaction with iface working --- modules/core/c++/id_map.hpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) (limited to 'modules/core') 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 find(const id& val){ + if(val.get_value() >= data_.size()){ + return make_error("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("ID value has already been freed"); + } + + return &data_.at(val.get_value()); + } }; } -- cgit v1.2.3