I want to have a ModelGenerator interface that has a generate () method that takes an iterable Evidence list and creates a model. Using the aliases of the STL pseudo-random interpretation iterator ...
template<class Model> class ModelGenerator { public: template<class Iterator> virtual bool generate(Iterator begin, Iterator end, Model& model) = 0; };
But virtual functions cannot be templates. Therefore, I need to create a template for the whole class:
template<class Model, class Iterator> class ModelGenerator { public: virtual bool generate(Iterator begin, Iterator end, Model& model) = 0; };
Ideally, what Id like to do is something like this ...
template<class Model, class Evidence> class ModelGenerator { public: virtual bool generate(iterator<Evidence>& begin, iterator<Evidence>& end, Model& model) = 0; };
But there is no interface that the iterator inherits. (The std :: iterator class contains only a set of typedefs, without methods.)
The only way I can do this is to give the ModelGenerator the addEvidence () method, which adds them one after the other before calling generate (), but then I have to give the ModelGenerator state, which is a little painful.
How can I write a virtual method that accepts any STL container?
source share