Home

On Oct 4, 10:48 am, Kai-Uwe Bux <jkherci...@gmx.net> wrote:
> Bruno wrote:
> > Thanks. I will do.

> > Btw, what's the point of the unary plus operator?
> > I can see a use for the unary -, but since integral pro,otion happens
> > automatically when it is needed, it seems redundant to me.

> One thing that comes to mind is that it renders expression like

> + some_var + some_other_var + yet_another_var

> legal. This can come in handy when you want to generate code
> mechanically: you do not need to treat the first summand in a
> special way. However, that is just speculation. I never had a
> use for unary +. But, it does not hurt, does it?

I suspect that there's an orthogonality issue involved. It
would seem rather odd to have unary minus, but not unary plus.

In another thread, Alf used +0 to force a char to be treated as
an int---unary plus would work as well (and be even more
obfuscation), e.g.:

char c = 'a' ;
std::cout << +c << std::endl ;

will display "97" on my machine, whereas without the +, it
displays "a" (but I still prefer "(int)( c )").

--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orientée objet/
Beratung in objektorientierter Datenverarbeitung
9 place Sémard, 78210 St.-Cyr-l'École, France, +33 (0)1 30 23 00 34

previous
next

Re: check whether internet connection is live from c++
Re: About const reference bounding to temporary variables.
Re: Where do I download Comeau compiler.
The meaning of a = b in object oriented languages
Re: Small changes in side library
Fundacja Hobbit
Niechciane i Zapomniane
Krwinka
Nasze Dzieci
Fundacja Avalon