title: Can I have a std::vector of template function pointers?
body: <p>I have a template function that I want to store a pointer to inside a <code>std::vector</code>.</p>
  
  <p>The function looks like this:</p>
  
  <pre><code>template&lt;typename T&gt; void funcName(T&amp; aT, std::vector&lt;std::string&gt;&amp; fileName){...}
  </code></pre>
  
  <p>Now I want to store multiple pointers to functions of this kind inside a <code>std::vector</code>. For non-template functions I would do it like this:</p>
  
  <pre><code>typedef std::vector&lt;std::string&gt; string_vt;
  typedef void func_t(T&amp;, string_vt&amp;);
  typedef func_t* funcPointer;
  typedef std::vector&lt;funcPointer&gt; funcPointer_vt;
  </code></pre>
  
  <p>But what is the correct syntax for template functions? How can I store them?</p>
  
  <p><strong>EDIT:</strong> First of all, thank you for your fast response. This was my first Question on Stack Overflow, so I am sorry for not providing enough information.</p>
  
  <p>The set of T is finite, it can either be of type ClassA or type classB. In these function templates I want to do changes to T (so either ClassA or ClassB) with some hard coded data. I have 8 of these functions, which basically initiate a default constructed T with data specific to the function. In my program, I want to initiate 2*8 default constructed T's (8 ClassA and 8 ClassB). Therefore I run a for loop, calling one function after the other, to initiate my T objects with the function's body data.</p>
  
  <pre><code>for(int i = 0; i &lt; initT.size(); ++i){
     init_T[i]&lt;T&gt;(someT, fileName);
  }
  </code></pre>
  
  <p>The for loop has as much iterations as there are function pointers inside the vector. At every iteration the function is called with some previously default constructed T and some other parameter. At the end the goal is to have 8 initiated T's with data specific to the function.</p>
  
  <p><strong>EDIT2:</strong> In case it helps, here is some actual source code. Inside the following function template I want to access my vector of function pointers in order to call the respective function.</p>
  
  <pre><code>template&lt;typename T_Relation, typename T_Relation_Vec, bool row&gt;
  void bulk_load(initRelation_vt&amp; aInitFunctions, T_Relation_Vec&amp; aRel_Vec, const bool aMeasure, const uint aRuns, const char* aPath)
  {
      for(size_t i = 0; i &lt; aRuns; ++i)
      {
          MemoryManager::freeAll();
          aRel_Vec.clear();
          string_vt fileNames;
          for(size_t j = 0; j &lt; aInitFunctions.size(); ++j)
          {
              aRel_Vec.emplace_back(T_Relation());
              aInitFunctions[j]&lt;T_Relation&gt;(aRel_Vec[j], fileNames);
              BulkLoader bl(fileNames[j].c_str(), tuples, aRel_Vec[j], delimiter, seperator);
              Measure lMeasure;
              if(aMeasure)
              {
                  lMeasure.start();
              }
              try
              {   
                  bl.bulk_load();
                  if(row)
                  {
                      BulkInsertSP bi;
                      bi.bulk_insert(bl, aRel_Vec[j]);
                  }
                  else
                  {
                      BulkInsertPAX bi;
                      bi.bulk_insert(bl, aRel_Vec[j]);
                  }
              }
              catch(std::exception&amp; ex)
              {
                  std::cerr &lt;&lt; "ERROR: " &lt;&lt; ex.what() &lt;&lt; std::endl;
              }
              lMeasure.stop();
              if(aMeasure)
              {
                  std::ofstream file;
                  file.open (aPath, std::ios::out | std::ios::app);
                  //print_result(file, flag, lMeasure.mTotalTime());
                  file.close();
              }
          }
      }
  }
  </code></pre>
  
  <p>This line is where the vector of function template pointers is accessed.</p>
  
  <pre><code>aInitFunctions[j]&lt;T_Relation&gt;(aRel_Vec[j], fileNames);
  </code></pre>