+ 1

Issue of shared_ptr array

Please refer code below and help me understand issue in code : Issue is last line where I have created array of shared pointer using make shared.... If I use unique pointer and make_unique for array , it works https://code.sololearn.com/coUjtrYcaZEY/?ref=app

24th Apr 2022, 1:50 PM
Ketan Lalcheta
Ketan Lalcheta - avatar
1 ответ
+ 1
Prior to C++20, there was no template specialization of std::make_shared<>() for array types: https://en.cppreference.com/w/cpp/memory/shared_ptr/make_shared Since the playground currently has C++17 enabled, the parameter is instead forwarded to the class constructor, but no such constructor exists. It works with std::make_unique<>() because the necessary specialization for arrays exists since C++14.
24th Apr 2022, 7:07 PM
Shadow
Shadow - avatar