Skip to content

Commit 60e013f

Browse files
committed
Fully enforce NonCopyable
Make NonCopyable fully operational so it gives compile errors in all build profiles.
1 parent aa6fd58 commit 60e013f

File tree

4 files changed

+4
-43
lines changed

4 files changed

+4
-43
lines changed

UNITTESTS/features/netsocket/TCPServer/test_TCPServer.cpp

Lines changed: 1 addition & 1 deletion
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(dynamic_cast<NetworkStack *>(&stack));
57+
TCPServer serverParam(dynamic_cast<NetworkStack *>(&stack));
5858
const SocketAddress a("127.0.0.1", 1024);
5959
EXPECT_EQ(serverParam.connect(a), NSAPI_ERROR_OK);
6060
}

UNITTESTS/features/netsocket/TCPSocket/test_TCPSocket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ TEST_F(TestTCPSocket, constructor)
6262

6363
TEST_F(TestTCPSocket, constructor_parameters)
6464
{
65-
TCPSocket socketParam = TCPSocket();
65+
TCPSocket socketParam;
6666
socketParam.open(dynamic_cast<NetworkStack *>(&stack));
6767
const SocketAddress a("127.0.0.1", 1024);
6868
EXPECT_EQ(socketParam.connect(a), NSAPI_ERROR_OK);

platform/NonCopyable.h

Lines changed: 0 additions & 39 deletions
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 */
@@ -178,39 +173,6 @@ class NonCopyable {
178173
*/
179174
~NonCopyable() = default;
180175

181-
#if (!defined(MBED_DEBUG) && (MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR == 0))
182-
/**
183-
* NonCopyable copy constructor.
184-
*
185-
* A compile time warning is issued when this function is used, and a runtime
186-
* warning is printed when the copy construction of the noncopyable happens.
187-
*
188-
* If you see this warning, your code is probably doing something unspecified.
189-
* Copying of noncopyable resources can lead to resource leak and random error.
190-
*/
191-
MBED_DEPRECATED("Invalid copy construction of a NonCopyable resource.")
192-
NonCopyable(const NonCopyable &)
193-
{
194-
debug("Invalid copy construction of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
195-
}
196-
197-
/**
198-
* NonCopyable copy assignment operator.
199-
*
200-
* A compile time warning is issued when this function is used, and a runtime
201-
* warning is printed when the copy construction of the noncopyable happens.
202-
*
203-
* If you see this warning, your code is probably doing something unspecified.
204-
* Copying of noncopyable resources can lead to resource leak and random error.
205-
*/
206-
MBED_DEPRECATED("Invalid copy assignment of a NonCopyable resource.")
207-
NonCopyable &operator=(const NonCopyable &)
208-
{
209-
debug("Invalid copy assignment of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
210-
return *this;
211-
}
212-
213-
#else
214176
private:
215177
/**
216178
* Declare copy constructor as private. Any attempt to copy construct
@@ -224,7 +186,6 @@ class NonCopyable {
224186
*/
225187
NonCopyable &operator=(const NonCopyable &);
226188
#endif
227-
#endif
228189
};
229190

230191
/**@}*/

platform/mbed_lib.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@
3737
},
3838

3939
"force-non-copyable-error": {
40-
"help": "Force compile time error when a NonCopyable object is copied",
41-
"value": false
40+
"help": "Force compile time error when a NonCopyable object is copied (obsolete option - always treated as true)",
41+
"value": true
4242
},
4343

4444
"poll-use-lowpower-timer": {

0 commit comments

Comments
 (0)