I suggest looking at the library of pointer containers from boost.
In addition, I would suggest that
Will tsMap [* tIter] and tsMap.find (* tIter) successfully find the correct associated value?
depends on the definition successfully. If the pointer identifier is a key identifier, yes. If you need to compare pointee objects instead, you need to provide an object for the comparison function (the called type in C ++ 0x).
Rather inefficient PoC: (see http://ideone.com/TpgLw )
#include <map> #include <functional> template <typename T> static bool indirectLess(const T* a, const T* b) { if (a==b) return false; if (!a) return true; if (!b) return false; return std::less<T>()(*a, *b); } typedef int T; typedef int V; int main() { typedef bool (*cmp_t)(const T*, const T*); std::map<T*,V,cmp_t> tsMap(&indirectLess<T>); }
source share