Глупый вопрос — а как правильно определять эту (полную) специализацию?
Обнаружил у себя два разных варианта:
template<>
inline void swap(MyClass1& x1,MyClass1& x2)
{
x1.swap(x2);
}//swap
template<>
inline void swap<MyClass2>(MyClass2& x1,MyClass2& x2)
{
x1.swap(x2);
}//swap
VS нормально переваривает оба варианта.
В данном конкретном случае, после swap нужно указывать в угловых скобках тип или не надо?
Или это дело вкуса?
-- Пользователи не приняли программу. Всех пришлось уничтожить. --
https://timsong-cpp.github.io/cppwp/n4659/temp.expl.spec#10:
A trailing template-argument can be left unspecified in the template-id naming an explicit function template specialization provided it can be deduced from the function argument type. [ Example:
template<class T> class Array { /* ... */ };
template<class T> void sort(Array<T>& v);
// explicit specialization for sort(Array<int>&)
// with deduced template-argument of type int
template<> void sort(Array<int>&);
— end example ]