The std::shared_ptr constructor isn\'t behaving as I expected:
#include
#include
void func(std::vector st
The constructor of shared_ptr takes a pointer of type T* as its argument, assumed to point to a dynamically allocated resource (or at least something that can be freed by the deleter). On the other hand, make_shared does the construction for you and takes the constructor arguments directly.
So either you say this:
std::shared_ptr p(new Foo('a', true, Blue));
Or, much better and more efficiently:
auto p = std::make_shared('a', true, Blue);
The latter form takes care of the allocation and construction for you, and in the process creates a more efficient implementation.
You could of course also say make_shared, but that would just create an unnecessary copy (which may be elided), and more importantly it creates needless redundancy. [Edit] For initializing your vector, this may be the best method:
auto p = std::make_shared(std::vector({"a", "b", "c"}));
The important point is, though, that make_shared performs the dynamic allocation for you, while the shared-ptr constructor does not, and instead takes ownership.