Specialization of std::shared_ptr
In C , std::unique_ptr has a template specialization for handling arrays, which appropriately invokes delete[] in its destructor. However, no such specialization exists for std::shared_ptr.
Why the Absence?
Initially, the oversight was likely due to time constraints, as the LWG (C committee) had many other pressing matters. However, the lack of a formal proposal also played a role.
Recent Developments
Informal discussions have brought the issue back to the forefront, and prototypes have been implemented. However, a formal proposal is still pending. Some LWG members believe that array support for std::shared_ptr would be a valuable addition.
Current Status
As of C 14, there is no built-in specialization for std::shared_ptr
Update
In 2014, a draft Technical Specification (TS) was proposed to add array support to std::shared_ptr. This proposal has been implemented in C 17.
The above is the detailed content of Why Doesn't `std::shared_ptr` Have a Specialization for Arrays in C ?. For more information, please follow other related articles on the PHP Chinese website!