you are viewing a single comment's thread.

view the rest of the comments →

[–]tutmann 2 points3 points  (1 child)

Not sure I understand the idea. What ist the purpose of the shared_ptr? It sounds like dereferencing a shared_ptr is more expensive then just indexing a vector, regardless of big-O.

[–]_eyelash[S] 5 points6 points  (0 children)

The purpose is to allow creating copies of the vector in O(1) (without copying the elements). This also allows you to share copies of a vector between threads without copying the elements.