Why use one vs the other: `boost::shared_array` VS `boost::shared_ptr`?

后端 未结 2 718
长情又很酷
长情又很酷 2021-01-06 09:02

So to deal with large blobs of memory either for an image or similar there are clearly lots of options.

Since I\'m a fan of smart pointers and RAII I\'m wondering ab

2条回答
  •  生来不讨喜
    2021-01-06 09:54

    shared_ptr to std::vector

    • + allows amortized constant time push_back
    • - introduces an extra level of indirection over std::vector

    shared_array

    • + does not introduce an extra level of indirection
    • - does not allow amortized constant time append, unless you implement it yourself, which again would take an extra level of indirection.

提交回复
热议问题