So I am working on a transformation from an OO-language with garbage collection capabilities to C++. To start out I want to wrap all objects in shared pointers to solve the memory de-allocation issue. Right now I am trying to wrap a vector in a shared pointer and initializing the vector directly. See the issue below. Why is it not working and, if possible, how do I make it work?
vector<int> vec({ 6, 4, 9 }); // Working
shared_ptr<vector<int>> vec = make_shared<vector<int>>({ 6, 4, 9 }); // Not working
Sorry for not including the error, the error I am getting is marked at (make_shared) and printed as:
no instance of function template "std::make_shared" matches the argument list
argument types are: ({...})
Thanks for any answers!
auto vec = make_shared<vector<int>>(std::initializer_list<int>{ 6, 4, 9 });
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With