title: How to save variable number of arguments using variadic template arguments?
body: <p>I would like to create template class which could store function pointer and arguments for a this function so the function can be later invoked with this arguments.</p>
  
  <p>I would like to write this universally and not to depend on argument types or number.</p>
  
  <p>Here is a scatch of the idea with the use of variadic templates of c++11:</p>
  
  <pre><code>template&lt;class T, typename... Params&gt;
  class LazyEvaluation {
  private:
      // Function to be invoked later
      T (*f)(Params...);
      // Params for function f
      Params... storedParams; // This line is not compilable!
      bool evaluated;
      T result;
  public:
      // Constructor remembers function pointer and parameters
      LazyEvaluation(T (*f)(Params...),Params... params)
      : f(f),
      storedParams(params) //this line also cannot be compiled
      {}
      // Method which can be called later to evaluate stored function with stored arguments
      operator T&amp;() {
              // if not evaluated then evaluate
              if (! evaluated) {
                      result = f(storedParams...);
                      evaluated = true;
              }
              return result;
       }
  }
  </code></pre>
  
  <p>I would like to have at least the public interface of this class type safe if it is possible. Although getting this work at least somehow is more important.</p>
  
  <p>I've managed to save the variable number of arguments somehow. But I wasn't able to pass them to the function f. I will write it to answers, but I would like you to think about your own solutions before you see my ugly not working attempt.</p>
  
  <p>I am tring to compile the code above with Microsoft Visual C++ Compiler Nov 2012 CTP (v120_CTP_Nov2012), but it would be best if a compiler independent solution would exist.</p>
  
  <p>Thank you</p>