Pocosharedptr smart pointer processing array method, pocosharedptr

Source: Internet
Author: User

Pocosharedptr smart pointer processing array method, pocosharedptr

Original article link

Poco SharedPtr has encountered some problems in the array processing process. For more information, see the official documentation for debugging and always report errors. After checking the source code, I finally found the problem and found many problems. In the case of source code, you can solve the problem by yourself through the source code. It may be because the official documents have not been updated for a long time. I hope you can read the source code in the future.

Template <class C> class ArrayReleasePolicy {public: static void release (C * pObj) // Delete the object. /// Note that pObj can be 0. {delete [] pObj ;}}; char * pStr = new char [100]; SharedPtr <char, Poco: ReferenceCounter, ArrayReleasePolicy> p (pStr );

The above use case provided by the official documentation is incorrect because the template requires the provision of data types

Template <class C> class ArrayReleasePolicy

The correct processing method should be:

Char * pStr = new char [100]; SharedPtr <char, Poco: ReferenceCounter, ArrayReleasePolicy <char> p (pStr );

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.