title: C++ Array or Vector of template classes with different value-type template parameters
body: <p>One application needs to handle a set of datasets on which some operations can be performed. Each data set contains an array of points of a specific data type (int32, int16, float, complex) and the same operations can be performed on the data contained in each data set. For example a Fourier Transform or a Filter. So in the Data Model (used in the model-view-controller pattern), i wanted to store the collection of open data sets, each with his own data type.</p>
  
  <p>Following <a href="https://stackoverflow.com/questions/696399/how-to-put-different-template-types-into-one-vector">How to put different template types into one vector</a>, to put template classes with different type parameters can be used inheritance or boost variants. </p>
  
  <p>I'd like to avoid the use of variants, and i would like to keep the value-type.</p>
  
  <p>What i would like is to store a vector (if possible, an array would be better) of classes with different template parameters:</p>
  
  <pre><code>    template &lt; typename T &gt;
      class DataSet {
        private:
        T data;
        // ...
         public:
        T getData() {return data;}
      };
  
      std::vector&lt; DataSet&lt; something &gt; &gt; v;
      v.push_back( DataSet&lt;int32_t*&gt;() );
      v.push_back( DataSet&lt;float*&gt;()   );
      v.push_back( DataSet&lt;int16_t*&gt;() );
  </code></pre>
  
  <p>What's the right approach to do this? Or to handle a collection of objects with different value-types on which i can perform the same operations?</p>