Add some typecasts to prevent copying a buffer twice (makes sure we find the correct overload of assign).