|
|
|
|
|
by Someone
4698 days ago
|
|
I agree with the 'make things const' part, but I would expect m_cachedWidth to be mutable. I'm too lazy to check that now, but if so, that would not help here. Even if it is not, I still think this is an example of "how you should modify your code". Reason? Doing temp = foo();
temp *= bar();
m_member = temp;
keeps your state consistent in case bar() throws. I would even use it if bar() is known not to throw, because you can't know what the future will bring, and because what you 'know' sometimes isn't true. Defensive programming, if easy as in this case, is a net benefit. |
|