Improve the performance of Boost.Function's swap. Thanks to Niels Dekker for the original patch. Fixes #1910