-4
#include<algorithm>
#include<string>
#include<new>
#include<memory>
#include<vector>
using std::vector;
using namespace std;
int main()
{

    shared_ptr<vector<int> > pointer=make_shared<vector<int>> ({2,3,5,8});
    cout<<(*pointer)[3];
    return 0;

so make_shared can't initialize like ({2,3,5,8}),why? }

1 Answers1

0

The function make_shared cannot forward intializer lists. If you need to use an initializer list constructor, you have to invoke the shared_ptr constructor directly.

Smeeheey
  • 9,906
  • 23
  • 39