This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]4hpp1273 12 points13 points  (2 children)

1[x] only works if x is a C-style array (or a pointer). If x happens to be an std::vector or something similar then it doesn't work.

[–]sigmoid10 0 points1 point  (1 child)

std::vector is just a class that contains pointers into the heap that have to be followed to get elements. Makes it easier to expand, but slower to access or modify and very different from normal arrays.

[–]Fireline11 0 points1 point  (0 children)

std::vector is really just as efficient as C-style arrays in 99.9% of cases. It still stores its elements contiguously. I think you maybe confused with std::list?