Question: I want to write a function that can take either of STL generic list, deque or vector and search for a key in it. What would be method signature of this function and how can we implement it?

What I know is that if we are accepting any of the derived classes in function argument we can use base abstract class assuming all relevant derived ones have the functions you need for your question.

**EDIT**: We cannot pass container's iterators in the function argument. If we can that is easy. It has to be a container.

I was thinking: Assuming 'Container' is an abstract base class from STL containers (which its not, according to first answer below).

template 
bool Search(std::Container C, T& key);

Thanks

Answer: 
As SergeyA mentioned in his answer, C++'s STL does not have polymorphic containers (opposing to Java or C# interfaces).

Regarding your requested function signature, look into STL `<algorithm>` header. There are lot of functions operating on some data, using two pointers (iterators) to the beginning and end of data block. For example,

```
template< class InputIt, class T >
InputIt find( InputIt first, InputIt last, const T& value );

```

searching for some `value` in `[first, last)`.

If you really want to pass whole container to the function, you'll similarly write

```
template<class Container, class T>
bool Search(const Container& container, const T& value)
{
    for (auto iterator = container.begin(); iterator != container.end(); ++iterator)
    {
        if (*iterator == value)
            return true;
    }
    return false;
}

```
Luckily for us, there is no base class for standard library containers. The only place I know of where polymorphic inheritance is used in standard library is streams, and this is what earned them such a bad fame.

Standard containers are non-polymorphic, thus fast. You will have to make your function template to work with any container.

For example,

```
template <class CONTAINER> bool exists(const CONTAINER& ctr, const typename CONTAINER::value_type& key); 

```