Click on blackbox.cpp to get source.
#include<iostream>
#include<list>
#include<vector>
#include<set>

using namespace std;
template <class vec>
class archetype {
public:
	virtual int apply(vec v) = 0;
};// end class archetype

template<class vec>
int gen_algo(archetype<vec>& B, vec v){return B.apply(v);}

class sparse_mat : public archetype<list<bool> >, public archetype<vector<float> >
{public:
	int apply(list<bool> v)
        {cout<<"calling sparse_mat.apply to list<bool>: ";
         return 1;}
	int apply(vector<float> v)
        {cout<<"calling sparse_mat.apply to vector<float>: ";
         return 2;}
};// end class sparse_mat

class mod_sparse_mat: public sparse_mat, public archetype< set<int> >
{public:
	int apply(set<int> v)
        {cout<<"calling mod_sparse_mat.apply to set<int>: ";
         return 3;}
	int apply(list<bool> v)
        {cout<<"calling mod_sparse_mat.apply to list<bool>:"<<endl<<"---";
         return sparse_mat::apply(v);}
	int apply(vector<float> v)
        {cout<<"calling mod_sparse_mat.apply to vector<float>:"<<endl<<"---";
         return sparse_mat::apply(v);}
};// end class mod_sparse_mat

int main(void)
{mod_sparse_mat A;
cout << "A.apply()" << endl;
cout << A.apply(list<bool>() ) << endl;
cout << A.apply(vector<float>() ) << endl;
cout << A.apply(set<int>() ) << endl;
cout << endl;

cout << "gen_algo(static_cast<archetype ... > >)" << endl;
cout << gen_algo(static_cast<archetype<list<bool> >& >(A), list<bool>() ) << endl;	
cout << gen_algo(static_cast<archetype<vector<float> >& >(A), vector<float>() ) << endl;	
cout << gen_algo(static_cast<archetype<set<int> >& >(A), set<int>() ) << endl;	
}