
22 Feb
2010
22 Feb
'10
6:03 p.m.
Given the very limited interface of tokenmap, you can easily implement in on top of a std::list, whose iterators do not get invalidated. I think Andrey's question is a critical one and has not yet been addressed.
Sharing implementation details such as iterators or pointers with external agents poses safety problems. The tokenmap introduces a lightweight level of indirection which hides implementation details. It also decouples the lifecycles of objects (the token can outlive the pointed to object, say stored in some context, and code can safely detect that). You can also think of tokenmap as provider of a "handle", an idiom popular in C.