2 ms·
Analysis is good, but I disagree with the conclusion. If you don't use operator[], then you don't pay for it, and I'm not sure how often this really matters.
by tedunangst 17y ago
Analysis is good, but I disagree with the conclusion. If you don't use operator[], then you don't pay for it, and I'm not sure how often this really matters. If you cared about performance, you'd be using more references and fewer copies.
- bensummers 17y agoIsn't the argument that using operator[] for read-only access has very unexpected performance issues?
- masklinn 17y ago> If you don't use operator[], then you don't pay for it The feature you pay for without using it is copy on write, not []. In fact it's very clear in the paragraph before the last chunk of code: > If you do use these functions, you risk paying for a write that you don't make
- tedunangst 17y agoI should have made more clear I never really expected COW, so I'm not terribly disappointed when I don't get it. The standard allows but doesn't require it, IIRC. But I don't see how I ever "pay" for COW. It's cheaper than copying when it works. Or, like I said, if you want copies, it's because you want copies. If you just want cheap references, use references.