Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Does it make sense to use std::shared_ptr<std::vector> instead of boost::shared_array?

Tags:

c++

c++11

stl

boost

Now I'm rewriting a part of my code to use C++11 standard. In some places I found the following code:

boost::shared_array<uint8_t> array;

Does it make to replace it with:

std::shared_ptr<std::vector<uint8_t>> array;

I'm trying to replace all boost's functionality that already presented in C++11 in my code.

I need to clarify a bit. Actually I need a raw array (but with refcount, so it can be automatically deleted), no need for all those vector features. So boost::shared_array solves the problem I want without any additional cost. But I'm trying to make my code uses new standard as much as possible (though many libraries from boost still not covered by the new standard).

Thanks.

like image 871
maverik Avatar asked May 13 '13 11:05

maverik


1 Answers

Given the current state of affairs in C++11 support in compilers and the laziness of people maintaing builds, I would leave that as-is now. Boost has the nice property of working virtually everywhere, including old compilers, and the change you want to make will hardly improve the code.

This code also isn't exactly the same.

like image 146
Bartek Banachewicz Avatar answered Nov 12 '22 23:11

Bartek Banachewicz