retdec
non_copyable.h
Go to the documentation of this file.
1 
7 #ifndef RETDEC_UTILS_NON_COPYABLE_H
8 #define RETDEC_UTILS_NON_COPYABLE_H
9 
10 namespace retdec {
11 namespace utils {
12 
27 class NonCopyable {
28 public:
29  // Disable copy constructor and assignment operator to prevent copying.
30  // They are declared public to make diagnostics messages more precise.
31  NonCopyable(const NonCopyable &) = delete;
32  NonCopyable &operator=(const NonCopyable &) = delete;
33 
34 protected:
35  // Public constructor is not needed in a mixin, so prevent the
36  // compiler from generating a public one.
37  NonCopyable() = default;
38 
39  // Protected non-virtual destructor disables polymorphic destruction, which
40  // is the appropriate behavior in this case.
41  ~NonCopyable() = default;
42 };
43 
44 } // namespace utils
45 } // namespace retdec
46 
47 #endif
A mixin to make classes non-copyable.
Definition: non_copyable.h:27
NonCopyable & operator=(const NonCopyable &)=delete
NonCopyable(const NonCopyable &)=delete
Definition: archive_wrapper.h:19