Skip to content

Commit acaf968

Browse files
author
Amanda Butler
authored
Copy edit NonCopyable.h
Make minor copy edits, mostly to existing text before this PR.
1 parent 0d2a8e0 commit acaf968

File tree

1 file changed

+30
-30
lines changed

1 file changed

+30
-30
lines changed

platform/NonCopyable.h

Lines changed: 30 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ namespace mbed {
3636
*
3737
* @par Usage
3838
*
39-
* To prevent generation of copy constructor and copy assignment operator simply
39+
* To prevent generation of copy constructor and copy assignment operator,
4040
* inherit privately from the NonCopyable class.
4141
*
4242
* @code
@@ -49,8 +49,8 @@ namespace mbed {
4949
*
5050
* @par Background information
5151
*
52-
* Instances of polymorphic classes are not meant to be copied. Unfortunately,
53-
* the C++ standards generates a default copy constructor and copy assignment
52+
* Instances of polymorphic classes are not meant to be copied. The
53+
* C++ standards generate a default copy constructor and copy assignment
5454
* function if these functions have not been defined in the class.
5555
*
5656
* Consider the following example:
@@ -79,18 +79,18 @@ namespace mbed {
7979
* Connection connection = get_connection();
8080
* @endcode
8181
*
82-
* There is a subtile bug in this code, the function get_connection returns a
82+
* There is a subtle bug in this code, the function get_connection returns a
8383
* reference to a Connection which is captured by value instead of reference.
8484
*
85-
* When the reference returned by get_connection is copied into connection, the
86-
* vtable and others members defined in Connection are copied but members defined
85+
* When the reference get_connection returns is copied into connection, the
86+
* vtable and others members defined in Connection are copied, but members defined
8787
* in SerialConnection are left apart. This can cause severe crashes or bugs if
88-
* the virtual functions captured uses members not present in the base
89-
* declaration.
88+
* the virtual functions captured use members not present in the base
89+
* declaration.
9090
*
9191
* To solve that problem, the copy constructor and assignment operator have to
92-
* be declared (but doesn't need to be defined) in the private section of the
93-
* Connection class:
92+
* be declared (but don't need to be defined) in the private section of the
93+
* Connection class:
9494
*
9595
* @code
9696
* struct Connection {
@@ -100,12 +100,12 @@ namespace mbed {
100100
* }
101101
* @endcode
102102
*
103-
* While manually declaring private copy constructor and assignment functions
104-
* works, it is not ideal as these declarations are usually not immediately
105-
* visible, easy to forget and may be obscure for uninformed programmer.
103+
* Although manually declaring private copy constructor and assignment functions
104+
* works, it is not ideal because these declarations are usually easy to forget,
105+
* not immediately visible and may be obscure for uninformed programmers.
106106
*
107-
* Using the NonCopyable class reduce the boilerplate required and express
108-
* clearly the intent as class inheritance appears right after the class name
107+
* Using the NonCopyable class reduces the boilerplate required and expresses
108+
* the intent because class inheritance appears right after the class name
109109
* declaration.
110110
*
111111
* @code
@@ -118,11 +118,11 @@ namespace mbed {
118118
* @par Implementation details
119119
*
120120
* Using a template type prevents cases where the empty base optimization cannot
121-
* be applied and therefore ensure that the cost of the NonCopyable semantic
121+
* be applied and therefore ensures that the cost of the NonCopyable semantic
122122
* sugar is null.
123123
*
124124
* As an example, the empty base optimization is prohibited if one of the empty
125-
* base class is also a base type of the first non static data member:
125+
* base classes is also a base type of the first nonstatic data member:
126126
*
127127
* @code
128128
* struct A { };
@@ -136,11 +136,11 @@ namespace mbed {
136136
* };
137137
*
138138
* // empty base optimization cannot be applied here because A from C and A from
139-
* // B shall have a different address. In that case, with the alignment
139+
* // B have a different address. In that case, with the alignment
140140
* // sizeof(C) == 2* sizeof(int)
141141
* @endcode
142142
*
143-
* The solution to that problem is to templatize the empty class to makes it
143+
* The solution to that problem is to templatize the empty class to make it
144144
* unique to the type it is applied to:
145145
*
146146
* @code
@@ -157,10 +157,10 @@ namespace mbed {
157157
* // kind of A. sizeof(C) == sizeof(B) == sizeof(int).
158158
* @endcode
159159
*
160-
* @tparam T The type that should be made non copyable.
160+
* @tparam T The type that should be made noncopyable.
161161
*
162-
* @note Compile time errors are disabled if the develop or the release profile
163-
* is used. To override this behavior and force compile time errors in all profile
162+
* @note Compile time errors are disabled if you use the develop or the release profile.
163+
* To override this behavior and force compile time errors in all profiles,
164164
* set the configuration parameter "platform.force-non-copyable-error" to true.
165165
*/
166166
template<typename T>
@@ -180,11 +180,11 @@ class NonCopyable {
180180
/**
181181
* NonCopyable copy constructor.
182182
*
183-
* A compile time warning is issued when this function is used and a runtime
184-
* warning is printed when the copy construction of the non copyable happens.
183+
* A compile time warning is issued when this function is used, and a runtime
184+
* warning is printed when the copy construction of the noncopyable happens.
185185
*
186186
* If you see this warning, your code is probably doing something unspecified.
187-
* Copy of non copyable resources can lead to resource leak and random error.
187+
* Copying of noncopyable resources can lead to resource leak and random error.
188188
*/
189189
MBED_DEPRECATED("Invalid copy construction of a NonCopyable resource.")
190190
NonCopyable(const NonCopyable &)
@@ -195,11 +195,11 @@ class NonCopyable {
195195
/**
196196
* NonCopyable copy assignment operator.
197197
*
198-
* A compile time warning is issued when this function is used and a runtime
199-
* warning is printed when the copy construction of the non copyable happens.
198+
* A compile time warning is issued when this function is used, and a runtime
199+
* warning is printed when the copy construction of the noncopyable happens.
200200
*
201201
* If you see this warning, your code is probably doing something unspecified.
202-
* Copy of non copyable resources can lead to resource leak and random error.
202+
* Copying of noncopyable resources can lead to resource leak and random error.
203203
*/
204204
MBED_DEPRECATED("Invalid copy assignment of a NonCopyable resource.")
205205
NonCopyable &operator=(const NonCopyable &)
@@ -211,13 +211,13 @@ class NonCopyable {
211211
#else
212212
private:
213213
/**
214-
* Declare copy constructor as private, any attempt to copy construct
214+
* Declare copy constructor as private. Any attempt to copy construct
215215
* a NonCopyable will fail at compile time.
216216
*/
217217
NonCopyable(const NonCopyable &);
218218

219219
/**
220-
* Declare copy assignment operator as private, any attempt to copy assign
220+
* Declare copy assignment operator as private. Any attempt to copy assign
221221
* a NonCopyable will fail at compile time.
222222
*/
223223
NonCopyable &operator=(const NonCopyable &);

0 commit comments

Comments
 (0)