Is there anything in C++11 STL that is equivalent or similar to objc_setAssociatedObject/objc_getAssociatedObject
in Objective-C ?
If not then is there any way by which i can achive the same behaviour in C++ ?
Is there anything in C++11 STL that is equivalent or similar to objc_setAssociatedObject/objc_getAssociatedObject
in Objective-C ?
If not then is there any way by which i can achive the same behaviour in C++ ?
No. There is nothing equivalent to obj_setAssociatedObject
.
You can get close with a static std::unordered_map
, but the really difficult bit is ensuring that deleting the owning object deletes the associated object. If you don't need that, or you can modify the owning object code to have it's own map, then you should be fine.
If you do need to delete an associated object when the owning object is deleted, and you can't alter the code of the associated object, then we need more details of your application to make sensible suggestions (I suggest asking another question rather than changing this one).