C++ Use of smart pointers inside STL containers -
what benefit of using smart pointers within stl containers ( vectors, maps etc... ) knowing these containers manages memory ?
example:
std::vector<std::unique_ptr<int>>
instead of
std::vector<int*>
if objects pointers not plenty manage memory pointers occupy. need manage pointers point to. thought store objects pointed instead of pointers (in case of illustration std::vector<int>
appropriate), however, in case have polymorphic objects not possible.
c++ stl smart-pointers
No comments:
Post a Comment