Why use one against the other: `boost :: shared_array` VS` boost :: shared_ptr <std :: vector>`?

Thus, in order to deal with large blocks of memory for an image or the like, there are many options.

Since I'm a fan of smart pointers and RAII, I wonder what it is smarter with:

  • a shared_ptrtostd::vector

or

  • go with shared_arraypointing to a dynamically allocated array.

What are the conceptual, practical, and operational consequences of choosing one and the other?

+4
source share
2 answers

This is the same as comparing the std :: vector array against C.

shared_array RAII C. . , , . , std::vector , .

std::vector, , .

+3

shared_ptr std::vector

  • + push_back
  • - std::vector

shared_array

  • +
  • - , , .
+2

All Articles