It is not allowed to specify default template arguments in the class template specialization. Use the following syntax to achieve what you want:
template <typename Comparator>
class Myclass<string, Comparator>
{
// ...
};
Question
template <typename _Type, typename _Comparator=less<typename _Type::value_type> >
class Myclass
// and then comes the rest of my class
I want to create a specialized template with strings (but also working with other comparator than the default one) I tried this but it is not compiling.
template <typename _Comparator=less<typename _Type::value_type> >
class Myclass<string>
I know that the next example works but it uses the default comparator I fixed.
template <>
class Myclass<string>
Solution
It is not allowed to specify default template arguments in the class template specialization. Use the following syntax to achieve what you want:
template <typename Comparator>
class Myclass<string, Comparator>
{
// ...
};
OTHER TIPS
You can make another default template parameter:
template<class Comparator = other_functor>
class Myclass<string, Comparator> {
};
Remove the =less<typename _Type::value_type>
when you declare the specialization.