Boost logo

Boost :

Subject: Re: [boost] [xint] Unary operator+
From: Daniel F. (the.source_at_[hidden])
Date: 2010-05-08 20:42:34


I sometimes like to use unary plus purely for aesthetic reasons.

That is, the following:

coordinates.push_back(new Vector(-w,-h));
coordinates.push_back(new Vector(+w,-h));
coordinates.push_back(new Vector(+w,+h));
coordinates.push_back(new Vector(-w,+h));

..looks nicer to me than:

coordinates.push_back(new Vector(-w,-h));
coordinates.push_back(new Vector(w,-h));
coordinates.push_back(new Vector(w,h));
coordinates.push_back(new Vector(-w,h));

Of course, I could (should?) always use whitespace...

Chad Nelson wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On 05/05/2010 01:37 PM, DE wrote:
>
>>>>>> Um, because that operator is used for i + j and returns the sum,
>>>>>> right? Did I miss something?
>>>>> I suspect you (Robert) might be looking at the unary + operator...
>>>> Doh! So I was. I didn't even look at the argument list when I saw
>>>> it because I've never overloaded the unary +!
>>> I don't know anyone who does, but I assume that someone out there,
>>> someone will, and would be irritated if it didn't work the same as the
>>> built in integer types.
>> that person is me definitly
>
> I was just wishing, when I wrote that, that I did know someone who did
> that... purely out of curiosity, I wanted to ask why they (i.e. you) did
> that? Is it just to make it more obvious that it's supposed to be a
> positive number instead of a negative one?
> - --
> Chad Nelson
> Oak Circle Software, Inc.
> *
> *
> *
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/
>
> iEYEARECAAYFAkvhxIgACgkQp9x9jeZ9/wQHwQCeNNN6/duASbCfwGiBdGH3vsvE
> 4doAn2yISlLUBsNXWqvdC7BoPRlznnTJ
> =k7dT
> -----END PGP SIGNATURE-----
> _______________________________________________
> Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
>


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