Quote:Original post by RavyneQuote:Original post by JohnBolton
These functions should return a reference to *this, not void.inline void operator =(const Vec3f &rhs); ...
This is actually a concious decision on my part for the sake of optimization. The returned reference is rarely used and, although technically 'correct' (or at least adhering to common practice,) promotes ugly code like a = b += c + d. So, to my mind, I've gained some optimization and prevented ugly code, and the fact that a direct reference to the variable in the next statement should be no less efficient seals the deal. Admittedly, it does go against the norm though.
hmmm... Returning void instead of a reference to Vec3f will not result in meaningful optimization (if any at all), and you are not preventing ugly code, you are reducing the usability of your class. You don't like using the result of an assignment, but others might find it valuable. Code using the result of assignment is very common (something like this perhaps):
while ( Vec3f::rad( v = GetVector() ) > 0 ) { // use v ... }
And since returning a reference to *this is the convention, your class would be considered broken by those that might depend on it.Just my opinion, so disregard if you like.