Map containing function pointers in C++
<p>The problem replace my if and else statements with a map that contains a string as a key and a function pointer as the value. However each function pointer can point to functions that have a different return type and different parameters without using boost. Basically what I'm wondering is how you create a map with generic function pointer as its value.</p>

<p>Below is simplified version of the problem I'm trying to solve. The desired output.</p>

<pre><code>#include&lt;iostream&gt;

int addtwoNumber(int a, int b){
    return a+b;
}
bool isEqual(std::string str, int number){
    return std::stoi(str)==number;
}

int main(){
    // create a map that contains funtion pointers
    template&lt;typename ReturnType, typename... Args&gt;
    std::map&lt;std::string, ReturnType (*)(Args...)&gt; actionMap; // create a map&lt;string, function pointer&gt;


    actionMap.insert(std::make_pair("one", &amp;addtwoNumber)); // add functions to the map
    actionMap.insert(std::make_pair("two", &amp;isEqual));

    std::cout &lt;&lt; "type commands and arguments: " &lt;&lt; std::endl;
    std::string command;
    std::cin &gt;&gt; command;
    auto func = actionMap.find(command[0]);
    std::cout &lt;&lt; *func() &lt;&lt; std::endl; // how do I pass the arguments to the function
}
</code></pre>

<p>Desired Output:</p>

<pre><code>./test.out              
one 2 5                  /user input
7                        /Output of the program
./test.out
two 5 5
true
</code></pre>