#include template struct foo { T t; foo():t(0){} void swop(foo& x) { using std::swap; swap(t,x.t); } }; template void swap(foo& x,foo& y) { x.swop(y); } int main() { foo x,y; x.swop(y); }