Original Post
I'm trying to store pointers to member functions in an std::map, but i've hit a bit of a roadblock. I keep getting buffer overuns using this code to copy the functions into the map:
std::string newName = name;
std::pair<std::string,InputPointer> inp( newName, point );
ent->inputs.insert( inp );
std::cout << "Input " << name << " registered" << std::endl;
the definition of InputPointer is like this: typedef void (BaseEntity::*InputPointer)(int); This is the Macro I used to call the above code: #define ENT_ADDINPUT( InputName, Pointer )
class C##InputName##Foo
{
public:
C##InputName##Foo( void )
{
std::cout << "address: " << Pointer << " Name: " << #InputName << std::endl;
std::string nInputName = #InputName;
Cell::EntityMap::getEntMap()->addInput(Cell::EntityMap::getEntMap()->getCurrent(), nInputName ,(Cell::InputPointer)Pointer);
}
};
static C##InputName##Foo mC##InputName##Foo;
//Here's the Macro Call
ENT_ADDINPUT( test, &BaseEntity::inputTest );
Anyone know what's going on? Incase you need to know, this is the memory from the std map after I call insert() http://i157.photobucket.com/albums/t62/danharibo/helpimtrapedinapointerfactory.png
