@@ -91,18 +91,16 @@ namespace mbed {
91
91
* in the base declaration.
92
92
*
93
93
* To solve that problem, the copy constructor and assignment operator have to
94
- * be declared (but don't need to be defined) in the private section of the
95
- * Connection class:
94
+ * be defined as deleted:
96
95
*
97
96
* @code
98
97
* struct Connection {
99
- * private:
100
- * Connection(const Connection&);
101
- * Connection& operator=(const Connection&);
98
+ * Connection(const Connection &) = delete;
99
+ * Connection &operator=(const Connection &) = delete;
102
100
* }
103
101
* @endcode
104
102
*
105
- * Although manually declaring private copy constructor and assignment functions
103
+ * Although manually defining deleted copy constructor and assignment functions
106
104
* works, it is not ideal. These declarations are usually easy to forget,
107
105
* not immediately visible, and may be obscure to uninformed programmers.
108
106
*
@@ -211,18 +209,18 @@ class NonCopyable {
211
209
}
212
210
213
211
#else
214
- private :
212
+ public :
215
213
/* *
216
- * Declare copy constructor as private . Any attempt to copy construct
214
+ * Define copy constructor as deleted . Any attempt to copy construct
217
215
* a NonCopyable will fail at compile time.
218
216
*/
219
- NonCopyable (const NonCopyable &);
217
+ NonCopyable (const NonCopyable &) = delete ;
220
218
221
219
/* *
222
- * Declare copy assignment operator as private . Any attempt to copy assign
220
+ * Define copy assignment operator as deleted . Any attempt to copy assign
223
221
* a NonCopyable will fail at compile time.
224
222
*/
225
- NonCopyable &operator =(const NonCopyable &);
223
+ NonCopyable &operator =(const NonCopyable &) = delete ;
226
224
#endif
227
225
#endif
228
226
};
0 commit comments