I am trying to write a helper class that would work with any kind of container of integers. Specifically, my class would lookup container values based on some criteria. In order to work with different types of containers, my class obviously needs to operate not on containers themselves but on container iterators. I am confused how to properly define and use this class.
template<class ForwardIt> // Do I have to template entire class?
class MyLookup {
public:
template<class ForwardIt> // Or may I just template the constructor
MyLookup(ForwardIt begin, ForwardIt end, ...)
}
Implementation is such that only class constructor needs to get begin/end iterator pair. My questions are:
- Do I have to template entire class or may I template just the constructor?
What is the correct way to instantiate the class? Compiler dislikes
MyLookUp< std::vector< int>::iterator> lookup(foo.begin(), foo.end(), ...)
THIS QUESTION WAS SUPERSEDED BY ANOTHER ONE