Ok guys I have been working on this now for a few days and I'm now running into another road block and I thought I would come to you guys and see if I can find a solution. So the problem I am having is working with function pointers, and std::function's in my code. So right now I'm using a map in the console system:
This is how it is defined.
std::map<std::string, std::function<void()>> m_commandMap;
The problem I'm having is with adding the commands to the map, I currently am using a function called AddCommand:
void Console::AddCommand(std::string commandName, void* funcPoint)
{
m_commandMap.insert(std::pair<std::string, std::function<void()>>(commandName, funcPoint));
}
I apologize if my syntax is incorrect but I'm not finding very much good information online about correct syntax of using std::function.
On top of this I have a function for processing the commands:
void Console::ProcessCommand(std::string commandName)
{
if (!commandName.empty())
{
auto functionIndex = m_commandMap.find(commandName);
if (functionIndex != m_commandMap.end())
{
functionIndex->second();
}
}
}
The part that I seem to be failing at is I can't figure out how to pass the function to the method AddCommand, what I have so far is:
editorConsole->AddCommand("FPS", TurnFPSOnOff);
But of course it doesn't like this line for how I'm passing the address of the function to Add Command It says the error is incompatible types of parameters. I am running out of ideas for how to handle it please help...