title: How to circumvent virtual template member functions?
body: <p>I have a template class <code>Field&lt;T&gt;</code> which inherits from a non-template abstract base class <code>AbstractField</code> to be able to store all different kinds of <code>Field&lt;T&gt; *</code> types in a <code>std::vector&lt;AbstractField *&gt;</code>. My setup is as follows:</p>
  
  <pre><code>#include &lt;vector&gt;
  
  class AbstractField
  {
      public:
          virtual ~AbstractField() {};
          // Something similar to: template&lt;class T&gt; T getValue() const; ?
  };
  
  template&lt;class T&gt;
  class Field : public AbstractField
  {
      private:
          T d_;
  
      public:    
          Field(T d) : d_(d) {}
          T getValue() const { return d_; }
  };
  
  int main()
  {
      AbstractField *f = new Field&lt;double&gt;(0.1);
      // How to call: f-&gt;getValue(); ?
  
      return 0;
  }
  </code></pre>
  
  <p>I was wondering what would be the most natural way to call <code>f-&gt;getValue()</code> since I can't use a virtual template member function in the <code>AbstractField</code> class. As far as possible, I would prefer not using boost. Any hints are welcome!</p>
  
  <p><strong>EDIT:</strong></p>
  
  <p>Corrected <code>std::vector&lt;Field&lt;T&gt; &gt;</code> to <code>std::vector&lt;AbstractField *&gt;</code>. Sorry for the confusion.</p>