4 ms·
Only to pedants. Everyone knows that adding a pointer to a ptrdiff_t calculated from the same array gives you another pointer. If your real life benchmark heav
by frutiger 6y ago
Only to pedants. Everyone knows that adding a pointer to a ptrdiff_t calculated from the same array gives you another pointer.
If your real life benchmark heavily penalises this addition (and not the complementary subtraction when computing a size or a capacity) I ask you to volunteer it.
- nikki93 6y agoIt's not simply pedantic, you would be interested in knowing that if you are interested in the implementation of vector-like data structures or if you want to implement one yourself, and the only motivation for that isn't that you are penalized in some benchmark. In article about the details of C++, and especially in a footnote, it's relevant IMO. It does happen that the only thing the point in the article relies on is `sizeof`, for sure.
- saagarjha 6y agoIt is not pedantic to reply to "std::vector is three pointers" with "actually, it might use a size instead of a pointer". Replying to "std::vector is often three pointers, or something functionally equivalent" with that would just be wrong. I have not made any claims about performance, but if I was asked to I would say that the difference is likely so minor that it doesn't matter.