Skip to content

Commit d089c86

Browse files
authored
Merge pull request #12581 from kjbracey-arm/hard_noncopy
Fully enforce NonCopyable
2 parents 149235f + 874e36e commit d089c86

File tree

3 files changed

+1
-45
lines changed

3 files changed

+1
-45
lines changed

UNITTESTS/features/netsocket/TCPServer/test_TCPServer.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ TEST_F(TestTCPServer, constructor)
5454

5555
TEST_F(TestTCPServer, constructor_parameters)
5656
{
57-
TCPServer serverParam = TCPServer(&stack);
57+
TCPServer serverParam(&stack);
5858
const SocketAddress a("127.0.0.1", 1024);
5959
EXPECT_EQ(serverParam.connect(a), NSAPI_ERROR_OK);
6060
}

platform/NonCopyable.h

-39
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,6 @@
1717
#ifndef MBED_NONCOPYABLE_H_
1818
#define MBED_NONCOPYABLE_H_
1919

20-
#if (!defined(MBED_DEBUG) && (MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR == 0))
21-
#include "platform/mbed_toolchain.h"
22-
#include "platform/mbed_debug.h"
23-
#endif
24-
2520
namespace mbed {
2621

2722
/** \addtogroup platform-public-api */
@@ -176,39 +171,6 @@ class NonCopyable {
176171
*/
177172
~NonCopyable() = default;
178173

179-
#if (!defined(MBED_DEBUG) && (MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR == 0))
180-
/**
181-
* NonCopyable copy constructor.
182-
*
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.
185-
*
186-
* If you see this warning, your code is probably doing something unspecified.
187-
* Copying of noncopyable resources can lead to resource leak and random error.
188-
*/
189-
MBED_DEPRECATED("Invalid copy construction of a NonCopyable resource.")
190-
NonCopyable(const NonCopyable &)
191-
{
192-
debug("Invalid copy construction of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
193-
}
194-
195-
/**
196-
* NonCopyable copy assignment operator.
197-
*
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.
200-
*
201-
* If you see this warning, your code is probably doing something unspecified.
202-
* Copying of noncopyable resources can lead to resource leak and random error.
203-
*/
204-
MBED_DEPRECATED("Invalid copy assignment of a NonCopyable resource.")
205-
NonCopyable &operator=(const NonCopyable &)
206-
{
207-
debug("Invalid copy assignment of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
208-
return *this;
209-
}
210-
211-
#else
212174
public:
213175
/**
214176
* Define copy constructor as deleted. Any attempt to copy construct
@@ -222,7 +184,6 @@ class NonCopyable {
222184
*/
223185
NonCopyable &operator=(const NonCopyable &) = delete;
224186
#endif
225-
#endif
226187
};
227188

228189
/**@}*/

platform/mbed_lib.json

-5
Original file line numberDiff line numberDiff line change
@@ -36,11 +36,6 @@
3636
"value": 9600
3737
},
3838

39-
"force-non-copyable-error": {
40-
"help": "Force compile time error when a NonCopyable object is copied",
41-
"value": false
42-
},
43-
4439
"poll-use-lowpower-timer": {
4540
"help": "Enable use of low power timer class for poll(). May cause missing events.",
4641
"value": false

0 commit comments

Comments
 (0)