UncopiableAndUnmovableClass.h
Go to the documentation of this file.
1 /**
2  * @file UncopiableAndUnmovableClass.h
3  * @brief Defines a class that can't be copied nor moved.
4  * @author Gianluca Petrillo (petrillo@fnal.gov)
5  *
6  * This library is currently a pure header.
7  *
8  */
9 
10 #ifndef COREUTILS_UNCOPIABLEANDUNMOVEABLECLASS_H
11 #define COREUTILS_UNCOPIABLEANDUNMOVEABLECLASS_H 1
12 
13 
14 namespace gar {
15 
16  /** **************************************************************************
17  * @brief An empty class that can't be copied nor moved
18  *
19  * A class derived from this one can still be copied (or moved)
20  * with an explicit effort. For example, to enable copy construction:
21  *
22  * struct CopiableClass: protected UncopiableAndUnmovableClass {
23  * CopiableClass(CopiableClass const& from)
24  * : UncopiableAndUnmovableClass() // , ...
25  * {
26  * // ...
27  * }
28  * };
29  *
30  * the default constructor of the base class can be called explicitly instead
31  * of the copy constructor. To provide an assignment operation,
32  *
33  * struct MoveAssignableClass: protected UncopiableAndUnmovableClass {
34  * MoveAssignableClass& operator= (MoveAssignableClass&& from)
35  * {
36  * // ...
37  * return *this;
38  * }
39  * };
40  *
41  *
42  */
44 
45  /// Default constructor
46  UncopiableAndUnmovableClass() = default;
47 
48  // @{
49  /// Deleted copy and move constructors and assignments
52 
54  (UncopiableAndUnmovableClass const&) = delete;
56  (UncopiableAndUnmovableClass&&) = delete;
57  // @}
58 
59  /// Default destructor
60  ~UncopiableAndUnmovableClass() = default;
61 
62  }; // UncopiableAndUnmovableClass
63 
64 
65 } // namespace gar
66 
67 #endif // COREUTILS_UNCOPIABLEANDUNMOVEABLECLASS_H
UncopiableAndUnmovableClass()=default
Default constructor.
General GArSoft Utilities.
~UncopiableAndUnmovableClass()=default
Default destructor.
An empty class that can't be copied nor moved.