• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1[/
2  Copyright 1999-2003 Beman Dawes
3  Copyright 2014 Peter Dimov
4
5  Distributed under the Boost Software License, Version 1.0.
6
7  See accompanying file LICENSE_1_0.txt
8  or copy at http://boost.org/LICENSE_1_0.txt
9]
10
11[section:noncopyable noncopyable]
12
13[simplesect Authors]
14
15* Dave Abrahams
16
17[endsimplesect]
18
19[section Header <boost/core/noncopyable.hpp>]
20
21The header `<boost/core/noncopyable.hpp>` defines the class
22`boost::noncopyable`. It is intended to be used as a private
23base class. `boost::noncopyable` has private (under C++03) or
24deleted (under C++11) copy constructor and a copy assignment
25operator and can't be copied or assigned; a class that derives
26from it inherits these properties.
27
28`boost::noncopyable` was originally contributed by Dave
29Abrahams.
30
31[section Synopsis]
32
33``
34namespace boost
35{
36    class noncopyable;
37}
38``
39
40[endsect]
41
42[section Example]
43
44``
45#include <boost/core/noncopyable.hpp>
46
47class X: private boost::noncopyable
48{
49};
50``
51
52[endsect]
53
54[section Rationale]
55
56Class noncopyable has protected constructor and destructor members to emphasize
57that it is to be used only as a base class. Dave Abrahams notes concern about
58the effect on compiler optimization of adding (even trivial inline) destructor
59declarations. He says:
60
61["Probably this concern is misplaced, because `noncopyable` will be used mostly
62for classes which own resources and thus have non-trivial destruction semantics.]
63
64With C++2011, using an optimized and trivial constructor and similar destructor
65can be enforced by declaring both and marking them `default`. This is done in
66the current implementation.
67
68[endsect]
69
70[endsect]
71
72[endsect]
73