[Home]  [Edit this page]  [Recent Changes]  [Special Pages]  [Help
CppScopedPtr

(C++) boost::scoped_ptr

The boost::scoped_ptr is a smart pointer supplied by the Boost C++ Library. It shared many characteristic with the std::auto_ptr.

Differences with the std::auto_ptr are:
  • A boost::scoped_ptr cannot be copied
  • A boost::scoped_ptr has a checked delete

About the checked delete (advanced)

When you make use of forward declaration and make a pointer to a forward declared class, you have to make sure that the destructor of this class is known at run-time. This, however, does not yield a compile-error, but in undefined behaviour ! A difficult error to spot!

If you want to make sure the condition above is true, use a boost::scoped_ptr. It will detect this at compile-time.

last edited (November 16, 2006) by bilderbikkel, Number of views: 2280, Current Rev: 3 (Diff)

[Edit this page]  [Page history]  [What links here]  [Discuss this topic]  [Printer Friendly]  

Members

Username:

Password:


Register
Forgot Password?




Programmers Heaven - for .NET, Java, C/C++ and WEB Developers!
© 1996-2008 Community Networks Ltd. All rights reserved. Reproduction in whole or in part, in any form or medium without express written permission is prohibited. Violators of this policy may be subject to legal action. Please read Terms Of Use and Privacy Statement for more information. Development by Tore Nestenius at .NET Consultant - Synchron Data.