I can, but I wouldn't because it's ugly and it doesn't solve the problem of "future bugs for everyone who never uses bitwise xor!". The whole point of having an operator is to provide a more intuitive way of using a function. IMHO addition of cross(v1, v2) or v1.cross(v2) would be nicer, along with the doxygen note warning about the issue regarding operator precedence.
-Gazi On 23/02/07, Eric Sokolowsky <[EMAIL PROTECTED]> wrote:
Gazi Alankus wrote: > I recently discovered a bug in my code that made me question the > choice of the operator chosen for vector cross product in osg. > The bitwise xor operator (^) has a lower precedence than addition > operator (+) in C++. So, addition is done before cross product, which > is not intuitive and is not the case in mathematics. I decided to stop > using the ^ operator for cross product, but I couldn't find a function > version for it - the operator looks like the only choice. I know I can > write one myself, but I just wanted to point this issue out since it > probably will lead to bugs in many other people's code. > > My apologies if I'm missing something. In C++, the ^ operator is nothing more than an overloaded operator^() that takes the right arguments. Therefore, instead of writing: a ^ b You can write: operator^(a, b) And since function calls have a very high precedence (and the comma operator has a very low precedence) this might achieve your goal. _______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
_______________________________________________ osg-users mailing list [email protected] http://openscenegraph.net/mailman/listinfo/osg-users http://www.openscenegraph.org/
