Virtual templates members of class workaround
<p>Let's say that I want to implement some classes for containers. All of them should implement such functions like insert, remove etc. So I write some interface:</p>

<pre><code>template &lt;class T&gt;
class ContainerInterface {
public:
   virtual void insert(T element) = 0;

   template&lt;class Predicate&gt;
   virtual void remove(Predicate p) = 0; 
};
</code></pre>

<p>Now I can write something like:</p>

<pre><code>template &lt;class T&gt;
class MyVector : public ContainerInterface&lt;T&gt;{};

template &lt;class T&gt;
class MyList : public ContainerInterface&lt;T&gt;{};
</code></pre>

<p>And I am sure that MyVector and MyList must implement functions insert and remove. However, there is the error:</p>

<pre><code>error: templates may not be ‘virtual’
</code></pre>

<p>It comes from:</p>

<pre><code>template&lt;class Predicate&gt;
virtual void remove(Predicate p) = 0; 
</code></pre>

<p>I don't know the Predicate when I define some container and I dont'see any sense to bind deleter object to container class, for example one time I can pass Predicate to delete integers less than 50 and other time I want delete even integers. What can be done in such case - to declare some templated thing in base class and simulate virtual behaviour of function?</p>
