SWAP VALUE

R

Richard Herring

Lionel B <[email protected]> said:
In message said:
In message <[email protected]>,

Pramod wrote:
On Jun 12, 4:26 pm, Ron Natalie <[email protected]> wrote:
[...]
buddy i want another method...to swap value if u have then post.

Nice manners there guy (or gal)...
[...]

will give me code

Is that a threat?
[...]
its not a threat....what's its mean 'u' "you"

Not everyone reading this newsgroup is a native speaker of English. Out
of consideration for them, please use proper English, not abbreviations
like "u" when you mean "you".
u have no manners
to talk any unknown people

PKB. "U" have no manners to *demand* that other people "will give you
code".

Calm down, people. To be fair to the OP, he is evidently not a native
English speaker and you might consider the possibility that he really
didn't intend his... ah... "requests" to come across as demands/threats.
<whoooosh>

ObC++:

Language aside, his "requests" are for something unreasonable, as other
posters (and the part of my post you snipped) made clear. Since we know
nothing about the types he's trying to swap, it's impossible to propose
a solution that's guaranteed to work.
 
J

James Kanze

Well it almost certainly doesn't always use the first method.
For classes it can be specialized to swap the internal members
without copying the entire object.

Good point. I was, of course, thinking of the generic
implementation, but you're 100% right. One should *always* use
std::swap, rather than doing it yourself, because classes can
often get by with a shallow swap, whereas the basic, generic
algorithm does a couple of deep copies. If you're swapping
containers, it can make an enormous difference.

In such cases, too, the fact that the specialized std::swap
cannot raise an exception, where as the generic form might, can
be even more important than the time saved.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
474,291
Messages
2,571,453
Members
48,132
Latest member
AnneHarpur

Latest Threads

Top