free-function

Partial template specialization of free functions - best practices

As most C++ programmers should know, partial template specialization of free functions is disallowed. For example, the following is illegal C++: template <class T, int N> T mul(const T& x) { return x * N; } template <class T> T mul<T, 0>(const T& x) { return T(0); } // error: function template partial specialization ‘mul<T, 0>’ is not...

Can C++ assignment operators be free functions?

I'm trying something like this: Foo & operator=(Foo & to, const Bar &from); But I'm getting this error: E2239 'operator =(Foo &, const Bar &)' must be a member function Are there limitations on which operators can/cannot be defined as Free Functions, and if so, why? ...