I'm implementing a custom map class similar to the one from std, however I have one problem.In their map, when you do(for instance):
map<string, SomeObject*> container;
SomeObject* object = container["this doesn't exist"];
in the debugger object is 0x0000000, so invalid values from map are always null.However, in my map invalid values are like uninitialized pointers - they have an invalid value like 0xcdcdcdcd, however in Release mode its something else, so I cant rely to check for
if(object == 0xcdcdcdcd)
So I would like to be able to do this:
MyMap<string, SomeObject*> container;
SomeObject* object = container["this doesn't exist"]; //and for this to definetely be nullptr
so I can then do
if(object == nullptr)
DoSomething();
I have a bool ContainsKey(KeyType key); function, but it involves a for loop.Is there some way to ensure what I want in initialization-time for the map, or do I have to make a custom PointerWrapper that will contain a pointer of SomeObject that is set to nullptr in PointerWrapper's constructor?I had a hard time figuring out what is going on in the std headers, they have an enormous amount of macros and typedefs.