Is it possible to do template specializations with the same body for unrelated types?

Code:
template <typename T>
void f(T &x) { ... default implementation }

template<>
void f(A &x) { ... specialized implementation for T=A }

template<>
void f(B &x) { ... specialized implementation for T=B }
If the bodies of the 2 specializations are the same (even though A and B are totally unrelated types), is there a way to remove code duplication?