]> git.proxmox.com Git - ceph.git/blob - ceph/src/boost/libs/core/doc/noncopyable.qbk
add subtree-ish sources for 12.0.3
[ceph.git] / ceph / src / boost / libs / core / doc / noncopyable.qbk
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
21 The header `<boost/noncopyable.hpp>` defines the class
22 `boost::noncopyable`. It is intended to be used as a private
23 base. `boost::noncopyable` has private (under C++03) or
24 deleted (under C++11) copy constructor and a copy assignment
25 operator and can't be copied or assigned; a class that derives
26 from it inherits these properties.
27
28 `boost::noncopyable` was originally contributed by Dave
29 Abrahams.
30
31 [section Synopsis]
32
33 ``
34 namespace boost
35 {
36 class noncopyable;
37 }
38 ``
39
40 [endsect]
41
42 [section Example]
43
44 ``
45 #include <boost/core/noncopyable.hpp>
46
47 class X: private boost::noncopyable
48 {
49 };
50 ``
51
52 [endsect]
53
54 [section Rationale]
55
56 Class noncopyable has protected constructor and destructor members to emphasize
57 that it is to be used only as a base class. Dave Abrahams notes concern about
58 the effect on compiler optimization of adding (even trivial inline) destructor
59 declarations. He says:
60
61 ["Probably this concern is misplaced, because `noncopyable` will be used mostly
62 for classes which own resources and thus have non-trivial destruction semantics.]
63
64 With C++2011, using an optimized and trivial constructor and similar destructor
65 can be enforced by declaring both and marking them `default`. This is done in
66 the current implementation.
67
68 [endsect]
69
70 [endsect]
71
72 [endsect]