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> >, archetype<vector<float> >
{public:
	int apply(list<bool> v){return 1;}
	int apply(vector<float> v){return 2;}
};// end class sparse_mat

class mod_sparse_mat: public sparse_mat, archetype< set<int> >
{public:
	int apply(set<int> v){return 3;}
	int apply(list<bool> v){return sparse_mat::apply(v);}
	int apply(vector<float> v){return sparse_mat::apply(v);}
};// end class mod_sparse_mat

int main(void)
{mod_sparse_mat A;
	cout << A.apply(list<bool>() ) << endl;
	cout << A.apply(vector<float>() ) << endl;
	cout << A.apply(set<int>() ) << 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;	
}