blob: 3290777c024ce0014b29be7e3ea08cf6edf0024a [file] [log] [blame]
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=US-ASCII">
<title>noncopyable</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&#160;1.&#160;Boost.Core">
<link rel="up" href="../index.html" title="Chapter&#160;1.&#160;Boost.Core">
<link rel="prev" href="no_exceptions_support.html" title="no_exceptions_support">
<link rel="next" href="null_deleter.html" title="null_deleter">
</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="no_exceptions_support.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="null_deleter.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.noncopyable"></a><a class="link" href="noncopyable.html" title="noncopyable">noncopyable</a>
</h2></div></div></div>
<div class="toc"><dl class="toc"><dt><span class="section"><a href="noncopyable.html#core.noncopyable.header_boost_core_noncopyable_hp">Header
&lt;boost/core/noncopyable.hpp&gt;</a></span></dt></dl></div>
<div class="simplesect">
<div class="titlepage"><div><div><h3 class="title">
<a name="idp86898192"></a>Authors</h3></div></div></div>
<div class="itemizedlist"><ul class="itemizedlist" style="list-style-type: disc; "><li class="listitem">
Dave Abrahams
</li></ul></div>
</div>
<div class="section">
<div class="titlepage"><div><div><h3 class="title">
<a name="core.noncopyable.header_boost_core_noncopyable_hp"></a><a class="link" href="noncopyable.html#core.noncopyable.header_boost_core_noncopyable_hp" title="Header &lt;boost/core/noncopyable.hpp&gt;">Header
&lt;boost/core/noncopyable.hpp&gt;</a>
</h3></div></div></div>
<p>
The header <code class="computeroutput"><span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">noncopyable</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span></code>
defines the class <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span></code>. It is intended to be used
as a private base. <code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span></code>
has private (under C++03) or deleted (under C++11) copy constructor and a
copy assignment operator and can't be copied or assigned; a class that derives
from it inherits these properties.
</p>
<p>
<code class="computeroutput"><span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span></code> was originally contributed
by Dave Abrahams.
</p>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.noncopyable.header_boost_core_noncopyable_hp.synopsis"></a><a class="link" href="noncopyable.html#core.noncopyable.header_boost_core_noncopyable_hp.synopsis" title="Synopsis">Synopsis</a>
</h4></div></div></div>
<pre class="programlisting"><span class="keyword">namespace</span> <span class="identifier">boost</span>
<span class="special">{</span>
<span class="keyword">class</span> <span class="identifier">noncopyable</span><span class="special">;</span>
<span class="special">}</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.noncopyable.header_boost_core_noncopyable_hp.example"></a><a class="link" href="noncopyable.html#core.noncopyable.header_boost_core_noncopyable_hp.example" title="Example">Example</a>
</h4></div></div></div>
<pre class="programlisting"><span class="preprocessor">#include</span> <span class="special">&lt;</span><span class="identifier">boost</span><span class="special">/</span><span class="identifier">core</span><span class="special">/</span><span class="identifier">noncopyable</span><span class="special">.</span><span class="identifier">hpp</span><span class="special">&gt;</span>
<span class="keyword">class</span> <span class="identifier">X</span><span class="special">:</span> <span class="keyword">private</span> <span class="identifier">boost</span><span class="special">::</span><span class="identifier">noncopyable</span>
<span class="special">{</span>
<span class="special">};</span>
</pre>
</div>
<div class="section">
<div class="titlepage"><div><div><h4 class="title">
<a name="core.noncopyable.header_boost_core_noncopyable_hp.rationale"></a><a class="link" href="noncopyable.html#core.noncopyable.header_boost_core_noncopyable_hp.rationale" title="Rationale">Rationale</a>
</h4></div></div></div>
<p>
Class noncopyable has protected constructor and destructor members to emphasize
that it is to be used only as a base class. Dave Abrahams notes concern
about the effect on compiler optimization of adding (even trivial inline)
destructor declarations. He says:
</p>
<p>
<span class="quote">&#8220;<span class="quote">Probably this concern is misplaced, because <code class="computeroutput"><span class="identifier">noncopyable</span></code>
will be used mostly for classes which own resources and thus have non-trivial
destruction semantics.</span>&#8221;</span>
</p>
<p>
With C++2011, using an optimized and trivial constructor and similar destructor
can be enforced by declaring both and marking them <code class="computeroutput"><span class="keyword">default</span></code>.
This is done in the current implementation.
</p>
</div>
</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 &#169; 2014 Peter Dimov<br>Copyright &#169; 2014 Glen Fernandes<br>Copyright &#169; 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="no_exceptions_support.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="null_deleter.html"><img src="../../../../../doc/src/images/next.png" alt="Next"></a>
</div>
</body>
</html>