| <html> |
| <head> |
| <meta http-equiv="Content-Type" content="text/html; charset=US-ASCII"> |
| <title>checked_delete</title> |
| <link rel="stylesheet" href="../../../../../doc/src/boostbook.css" type="text/css"> |
| <meta name="generator" content="DocBook XSL Stylesheets V1.78.1"> |
| <link rel="home" href="../index.html" title="Chapter 1. Boost.Core"> |
| <link rel="up" href="../index.html" title="Chapter 1. Boost.Core"> |
| <link rel="prev" href="addressof.html" title="addressof"> |
| <link rel="next" href="demangle.html" title="demangle"> |
| </head> |
| <body bgcolor="white" text="black" link="#0000FF" vlink="#840084" alink="#0000FF"> |
| <table cellpadding="2" width="100%"><tr> |
| <td valign="top"><img alt="Boost C++ Libraries" width="277" height="86" src="../../../../../boost.png"></td> |
| <td align="center"><a href="../../../../../index.html">Home</a></td> |
| <td align="center"><a href="../../../../../libs/libraries.htm">Libraries</a></td> |
| <td align="center"><a href="http://www.boost.org/users/people.html">People</a></td> |
| <td align="center"><a href="http://www.boost.org/users/faq.html">FAQ</a></td> |
| <td align="center"><a href="../../../../../more/index.htm">More</a></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="addressof.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="demangle.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h2 class="title" style="clear: both"> |
| <a name="core.checked_delete"></a><a class="link" href="checked_delete.html" title="checked_delete">checked_delete</a> |
| </h2></div></div></div> |
| <div class="toc"><dl class="toc"> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.overview">Overview</a></span></dt> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.synopsis">Synopsis</a></span></dt> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.checked_delete">checked_delete</a></span></dt> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.checked_array_delete">checked_array_delete</a></span></dt> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.checked_deleter">checked_deleter</a></span></dt> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.checked_array_deleter">checked_array_deleter</a></span></dt> |
| <dt><span class="section"><a href="checked_delete.html#core.checked_delete.acknowledgements">Acknowledgements</a></span></dt> |
| </dl></div> |
| <div class="simplesect"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="idp85319968"></a>Authors</h3></div></div></div> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| Beman Dawes |
| </li> |
| <li class="listitem"> |
| Dave Abrahams |
| </li> |
| <li class="listitem"> |
| Vladimir Prus |
| </li> |
| <li class="listitem"> |
| Rainer Deyke |
| </li> |
| <li class="listitem"> |
| John Maddock |
| </li> |
| </ul></div> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.overview"></a><a class="link" href="checked_delete.html#core.checked_delete.overview" title="Overview">Overview</a> |
| </h3></div></div></div> |
| <p> |
| The header <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">checked_delete</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code> |
| defines two function templates, <code class="computeroutput"><span class="identifier">checked_delete</span></code> |
| and <code class="computeroutput"><span class="identifier">checked_array_delete</span></code>, |
| and two class templates, <code class="computeroutput"><span class="identifier">checked_deleter</span></code> |
| and <code class="computeroutput"><span class="identifier">checked_array_deleter</span></code>. |
| </p> |
| <p> |
| The C++ Standard allows, in 5.3.5/5, pointers to incomplete class types to |
| be deleted with a delete-expression. When the class has a non-trivial destructor, |
| or a class-specific operator delete, the behavior is undefined. Some compilers |
| issue a warning when an incomplete type is deleted, but unfortunately, not |
| all do, and programmers sometimes ignore or disable warnings. |
| </p> |
| <p> |
| A particularly troublesome case is when a smart pointer's destructor, such |
| as <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">scoped_ptr</span><span class="special"><</span><span class="identifier">T</span><span class="special">>::~</span><span class="identifier">scoped_ptr</span></code>, is instantiated with an incomplete |
| type. This can often lead to silent, hard to track failures. |
| </p> |
| <p> |
| The supplied function and class templates can be used to prevent these problems, |
| as they require a complete type, and cause a compilation error otherwise. |
| </p> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.synopsis"></a><a class="link" href="checked_delete.html#core.checked_delete.synopsis" title="Synopsis">Synopsis</a> |
| </h3></div></div></div> |
| <pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span> |
| <span class="special">{</span> |
| <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">checked_delete</span><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">);</span> |
| <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">void</span> <span class="identifier">checked_array_delete</span><span class="special">(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">);</span> |
| <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">checked_deleter</span><span class="special">;</span> |
| <span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">checked_array_deleter</span><span class="special">;</span> |
| <span class="special">}</span> |
| </pre> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.checked_delete"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_delete" title="checked_delete">checked_delete</a> |
| </h3></div></div></div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h4 class="title"> |
| <a name="core.checked_delete.checked_delete.template_class_t_void_checked_de"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_delete.template_class_t_void_checked_de" title="template<class T> void checked_delete(T * p);">template<class |
| T> void checked_delete(T * p);</a> |
| </h4></div></div></div> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> |
| must be a complete type. The expression <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="identifier">p</span></code> must be well-formed. |
| </li> |
| <li class="listitem"> |
| <span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="identifier">p</span><span class="special">;</span></code> |
| </li> |
| </ul></div> |
| </div> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.checked_array_delete"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_array_delete" title="checked_array_delete">checked_array_delete</a> |
| </h3></div></div></div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h4 class="title"> |
| <a name="core.checked_delete.checked_array_delete.template_class_t_void_checked_ar"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_array_delete.template_class_t_void_checked_ar" title="template<class T> void checked_array_delete(T * p);">template<class |
| T> void checked_array_delete(T * p);</a> |
| </h4></div></div></div> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> |
| must be a complete type. The expression <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="special">[]</span> <span class="identifier">p</span></code> |
| must be well-formed. |
| </li> |
| <li class="listitem"> |
| <span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="special">[]</span> <span class="identifier">p</span><span class="special">;</span></code> |
| </li> |
| </ul></div> |
| </div> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.checked_deleter"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_deleter" title="checked_deleter">checked_deleter</a> |
| </h3></div></div></div> |
| <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">checked_deleter</span> |
| <span class="special">{</span> |
| <span class="keyword">typedef</span> <span class="keyword">void</span> <span class="identifier">result_type</span><span class="special">;</span> |
| <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="special">*</span> <span class="identifier">argument_type</span><span class="special">;</span> |
| <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> |
| <span class="special">};</span> |
| </pre> |
| <div class="section"> |
| <div class="titlepage"><div><div><h4 class="title"> |
| <a name="core.checked_delete.checked_deleter.void_checked_deleter_t_operator_"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_deleter.void_checked_deleter_t_operator_" title="void checked_deleter<T>::operator()(T * p) const;">void |
| checked_deleter<T>::operator()(T * p) const;</a> |
| </h4></div></div></div> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> |
| must be a complete type. The expression <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="identifier">p</span></code> must be well-formed. |
| </li> |
| <li class="listitem"> |
| <span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="identifier">p</span><span class="special">;</span></code> |
| </li> |
| </ul></div> |
| </div> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.checked_array_deleter"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_array_deleter" title="checked_array_deleter">checked_array_deleter</a> |
| </h3></div></div></div> |
| <pre class="programlisting"><span class="keyword">template</span><span class="special"><</span><span class="keyword">class</span> <span class="identifier">T</span><span class="special">></span> <span class="keyword">struct</span> <span class="identifier">checked_array_deleter</span> |
| <span class="special">{</span> |
| <span class="keyword">typedef</span> <span class="keyword">void</span> <span class="identifier">result_type</span><span class="special">;</span> |
| <span class="keyword">typedef</span> <span class="identifier">T</span> <span class="special">*</span> <span class="identifier">argument_type</span><span class="special">;</span> |
| <span class="keyword">void</span> <span class="keyword">operator</span><span class="special">()(</span><span class="identifier">T</span> <span class="special">*</span> <span class="identifier">p</span><span class="special">)</span> <span class="keyword">const</span><span class="special">;</span> |
| <span class="special">};</span> |
| </pre> |
| <div class="section"> |
| <div class="titlepage"><div><div><h4 class="title"> |
| <a name="core.checked_delete.checked_array_deleter.void_checked_array_deleter_t_ope"></a><a class="link" href="checked_delete.html#core.checked_delete.checked_array_deleter.void_checked_array_deleter_t_ope" title="void checked_array_deleter<T>::operator()(T * p) const;">void |
| checked_array_deleter<T>::operator()(T * p) const;</a> |
| </h4></div></div></div> |
| <div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "> |
| <li class="listitem"> |
| <span class="bold"><strong>Requires:</strong></span> <code class="computeroutput"><span class="identifier">T</span></code> |
| must be a complete type. The expression <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="special">[]</span> <span class="identifier">p</span></code> |
| must be well-formed. |
| </li> |
| <li class="listitem"> |
| <span class="bold"><strong>Effects:</strong></span> <code class="computeroutput"><span class="keyword">delete</span> |
| <span class="special">[]</span> <span class="identifier">p</span><span class="special">;</span></code> |
| </li> |
| </ul></div> |
| </div> |
| </div> |
| <div class="section"> |
| <div class="titlepage"><div><div><h3 class="title"> |
| <a name="core.checked_delete.acknowledgements"></a><a class="link" href="checked_delete.html#core.checked_delete.acknowledgements" title="Acknowledgements">Acknowledgements</a> |
| </h3></div></div></div> |
| <p> |
| The function templates <code class="computeroutput"><span class="identifier">checked_delete</span></code> |
| and <code class="computeroutput"><span class="identifier">checked_array_delete</span></code> |
| were originally part of <code class="computeroutput"><span class="special"><</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">utility</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">></span></code>, |
| and the documentation acknowledged Beman Dawes, Dave Abrahams, Vladimir Prus, |
| Rainer Deyke, John Maddock, and others as contributors. |
| </p> |
| </div> |
| </div> |
| <table xmlns:rev="http://www.cs.rpi.edu/~gregod/boost/tools/doc/revision" width="100%"><tr> |
| <td align="left"></td> |
| <td align="right"><div class="copyright-footer">Copyright © 2014 Peter Dimov<br>Copyright © 2014 Glen Fernandes<br>Copyright © 2014 Andrey Semashev<p> |
| Distributed under the <a href="http://boost.org/LICENSE_1_0.txt" target="_top">Boost |
| Software License, Version 1.0</a>. |
| </p> |
| </div></td> |
| </tr></table> |
| <hr> |
| <div class="spirit-nav"> |
| <a accesskey="p" href="addressof.html"><img src="../../../../../doc/src/images/prev.png" alt="Prev"></a><a accesskey="u" href="../index.html"><img src="../../../../../doc/src/images/up.png" alt="Up"></a><a accesskey="h" href="../index.html"><img src="../../../../../doc/src/images/home.png" alt="Home"></a><a accesskey="n" href="demangle.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a> |
| </div> |
| </body> |
| </html> |