advertisement
Premier Club Log In/Registration
  Include Code  Search Tips
TODAY'S HEADLINES  |   ARTICLE ARCHIVE  |   SKILLBUILDING  |   TIP BANK  |   SOURCEBANK  |   FORUMS  |   NEWSLETTERS
Browse DevX
"The introduction of shared_ptr makes a built-in garbage collector almost redundant in C++." What is your opinion? Let us know in our C++ Discussion Forum.
Partners & Affiliates
advertisement
advertisement
advertisement
Average Rating: 5/5 | Rate this item | 2 users have rated this item.
 

Automate Resource Management with shared_ptr

Your days of being frustrated by std::auto_ptr's limitations are over. The Library Extensions Technical Report 1 has added a new smart pointer class to the standard <memory> header. Find out how you can use shared_ptr to automate resource management and simplify common programming tasks. 

advertisement
td::auto_ptr is the only smart pointer class available in C++98. Alas, since this class is neither assignable nor copy-constructible, creating containers of auto_ptr objects is illegal. This limitation has been a source of frustration and confusion for years. At last, the Library Extensions Technical Report 1 (TR1 for short) rectifies this embarrassment, adding a new smart pointer class called shared_ptr to the standard header <memory>. The following sections explain how to use shared_ptr to automate resource management. You will also learn how shared_ptr can simplify programming tasks that I've shown here before—such as simulating heterogeneous containers and implementing the Pimpl idiom.


How to combine smart pointers with STL containers and algorithms without risking undefined behavior?


Use the std::tr1::shared_ptr class.

  Next Page: Presenting the Problem
Page 1: IntroductionPage 3: Counting on Reference Counting
Page 2: Presenting the ProblemPage 4: Pimpl Revisited
Please rate this item (5=best)
 1  2  3  4  5
advertisement
Advertising Info  |   Member Services  |   Permissions  |   Contact Us  |   Help  |   Feedback  |   Site Map  |   Network Map  |   About

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs