title: Storing function pointers in a std::map
body: <p>I am trying to store function pointers in a map, along with a structure. The idea is to execute the corresponding functions, when I find specific values in the structure. The program is not compiling, and giving me lot of errors when I am trying to insert data into the map through std::make_pair. Here is the code that I have written. Please guide me as to what I am doing wrong here..</p>
  
  <pre><code>#include "stdafx.h"
  #include &lt;iostream&gt;
  #include &lt;string&gt;
  #include &lt;map&gt;
  
  struct _timeset
  {
      int hr1;
      int min1;
      int secs1;
  };
  
  _timeset t1 = { 17, 10, 30 };
  
  void fun1(void)
  {
      std::cout &lt;&lt; "inside fun1\n";
  }
  
  void fun2(void)
  {
      std::cout &lt;&lt; "inside fun2\n";
  }
  
  void fun3(void)
  {
      std::cout &lt;&lt; "inside fun3\n";
  }
  
  std::map&lt;_timeset, void(*)()&gt; m1;
  
  int main()
  {
      m1.insert(std::make_pair(t1, fun1));  //Compiling errors here
  
  
  
      return 0;
  }
  </code></pre>
  
  <p>My basics in STL is very poor. I am using VS2013 Compiler.
  Also while iterating the map, can I execute the relevant function with something like :</p>
  
  <pre><code>std::map&lt;_timeset, void(*)()&gt;::iterator it1;
      int i = 0;
      for (i=0,it1 = m1.begin(); it1 != m1.end(); it1++,i++)
      {
  
          _timeset _t = it1-&gt;first;
           //Check Values in _t, and then execute the corresponding function in the map
  
              (*it1-&gt;second)();
      }
  </code></pre>
  
  <p>many thanks,</p>