Why does this function not deduce template arguments?
I have a template function like this:
1 2 3 4 5
|
template <typename T, template <typename> typename Container>
void sortContainer(Container<T>& cont)
{
std::sort(cont.begin(), cont.end());
}
|
types cannot be deduced as in the following:
1 2 3 4 5 6
|
void useSortContainer()
{
std::vector v{8, 4, 90, 12, -34};
sortContainer<int, std::vector>(v);
sortContainer(v); // THIS does not compile!
}
|
Thanks,
Juan
std::vector
has two template type parameters.
1 2
|
template<typename T, typename A, template <typename,typename> class Container >
void do_sort( Container<T,A>& cntr ) { std::sort( cntr.begin(), cntr.end() ) ; }
|
thank you!!
Topic archived. No new replies allowed.