I have a class called SmartMap. (how smart really depends I guess)
The way I originally made it was to use the type as the map element. This worked, but I need a different map for every type. So, I decided to make the map element a void* instead of the type itself, and just allow casting for the type.
This is the class so far. I know it sucks. That is why its here.
Here is the only implementation I could get to work. Which is really ugly.
SmartMap(HWND hwnd = 0):Hwnd(hwnd)
void* Push(const key& new_key, void* new_val = 0)
std::map<key, void*>::iterator finder = PtrMap.begin();
size_t loc = 0;
for (/**/; finder != PtrMap.end(); ++finder )
if ( (*finder).first == new_key )
ss1 << "Key Found: " << new_key << "\nKey Location: " << loc\
<< "\n\nCannot add new element. Key already exists.";
if ( new_val == 0 )
PtrMap[new_key] = new_val;
PtrMap[new_key] = new void*(new_val);
//The actual container
std::map<key, void*> PtrMap;
//The window for the messagebox calls
const SmartMap& operator=(const SmartMap&);
I am guessing that this is the only way to do this, but I am really not sure. Looking for input. Any help and I will be greatly appreciative.
int* t = (int*)test.Push('a',(void*)1001);
std::cout << *t << "\n\n";