Boost logo

Boost :

Subject: Re: [boost] [boost::endian] Request for comments/interest
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2010-05-27 05:55:54


On Thu, May 27, 2010 at 2:30 AM, Tomas Puverle
<Tomas.Puverle_at_[hidden]> wrote:
[...]
> My point was about the fact that if you have two functions with the following
> signatures
>
> template<typename T>
> void swap(T & t);
>
> template<typename T>
> T swap(const T & t);
>
> when the user has this
>
> int i;
>
> then there is no way to specify whether or not he wants the copying or the
> swap-in-place version (ok, I can think of a way but I think it's way too
> convoluted)
>

Static casting?

> swap(i); //what does this mean?
>
> I was just trying to explain why I chose to have a swap_in_place<>() rather
> than rely on overloading.
>

The biggest reason not to do that, IMHO, is that oveloards should
always have the same behavior.

-- 
gpd

Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk