Still not the best solution, but for now I go:
PointerMap<MyFoo>::Type myFoos; MyFoo * myFoo = new MyFoo(); myFoos.insert(PointerMap<MyFoo>::Item(myFoo));
Title:
#include <map> #include <memory> #include <utility> template<typename T> struct PointerMap { typedef std::map<T *, std::unique_ptr<T>> Type; struct Item : std::pair<T *, std::unique_ptr<T>> { Item(T * pointer) : std::pair<T *, std::unique_ptr<T>>(pointer, std::unique_ptr<T>(pointer)) { } }; };
mazatwork
source share