I'm trying to create full specialization of a function template:
#pragma once
#include <list>
template< template<typename T, typename A > typename C, typename T, typename A = std::allocator<T> >
void mysort2(C<T, A>& container)
{
std::sort(container.begin(), container.end());
}
template<>
void mysort2< std::list<int, std::allocator<int> >, int, std::allocator<int> >(std::list<int, std::allocator<int> >& mylist)
{
mylist.sort();
}
I get compile error messages:
1) no instance of function template "mysort2" matches the specified type
2) Error C2912 explicit specialization 'void mysort2>,int,std::allocator<_Ty>>(std::list<_Ty,std::allocator<_Ty>> &)' is not a specialization of a function template
Questions:
1) can this be done? How? 2) According to Scott Meyers, function template specialization should be discouraged. Shall this advice apply here? 3) What would be the recommended pattern?