Template function with template argument parametrized over int

Without using the features of C++11 and higher (I will accept them but would prefer C++98),

I have to write a template function with argument T which is an STL container of ints. It receives such a container along with another int which it tries to search for,

Right now I have this but it doesn't compile:

template <template<int> class T>
T::iterator easyfind(T &container, int val)
{
    T::iterator it = container.begin();
    for ( ; it != container.end(); it++)
        if (val == *it)
            break ;
    return (it);
}

I wonder if I can somehow force the T parameter to always be a class template that is parametrized over integers... I tried writing T<int> but it still doesn't compile.



from Recent Questions - Stack Overflow https://ift.tt/343GFZx
https://ift.tt/eA8V8J

Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation