Writing type conversion as template specializations