Skip to content

Fully enforce NonCopyable #12581

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion UNITTESTS/features/netsocket/TCPServer/test_TCPServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ TEST_F(TestTCPServer, constructor)

TEST_F(TestTCPServer, constructor_parameters)
{
TCPServer serverParam = TCPServer(&stack);
TCPServer serverParam(&stack);
const SocketAddress a("127.0.0.1", 1024);
EXPECT_EQ(serverParam.connect(a), NSAPI_ERROR_OK);
}
Expand Down
39 changes: 0 additions & 39 deletions platform/NonCopyable.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,6 @@
#ifndef MBED_NONCOPYABLE_H_
#define MBED_NONCOPYABLE_H_

#if (!defined(MBED_DEBUG) && (MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR == 0))
#include "platform/mbed_toolchain.h"
#include "platform/mbed_debug.h"
#endif

namespace mbed {

/** \addtogroup platform-public-api */
Expand Down Expand Up @@ -176,39 +171,6 @@ class NonCopyable {
*/
~NonCopyable() = default;

#if (!defined(MBED_DEBUG) && (MBED_CONF_PLATFORM_FORCE_NON_COPYABLE_ERROR == 0))
/**
* NonCopyable copy constructor.
*
* A compile time warning is issued when this function is used, and a runtime
* warning is printed when the copy construction of the noncopyable happens.
*
* If you see this warning, your code is probably doing something unspecified.
* Copying of noncopyable resources can lead to resource leak and random error.
*/
MBED_DEPRECATED("Invalid copy construction of a NonCopyable resource.")
NonCopyable(const NonCopyable &)
{
debug("Invalid copy construction of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
}

/**
* NonCopyable copy assignment operator.
*
* A compile time warning is issued when this function is used, and a runtime
* warning is printed when the copy construction of the noncopyable happens.
*
* If you see this warning, your code is probably doing something unspecified.
* Copying of noncopyable resources can lead to resource leak and random error.
*/
MBED_DEPRECATED("Invalid copy assignment of a NonCopyable resource.")
NonCopyable &operator=(const NonCopyable &)
{
debug("Invalid copy assignment of a NonCopyable resource: %s\r\n", MBED_PRETTY_FUNCTION);
return *this;
}

#else
public:
/**
* Define copy constructor as deleted. Any attempt to copy construct
Expand All @@ -222,7 +184,6 @@ class NonCopyable {
*/
NonCopyable &operator=(const NonCopyable &) = delete;
#endif
#endif
};

/**@}*/
Expand Down
5 changes: 0 additions & 5 deletions platform/mbed_lib.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
"value": 9600
},

"force-non-copyable-error": {
"help": "Force compile time error when a NonCopyable object is copied",
"value": false
},

"poll-use-lowpower-timer": {
"help": "Enable use of low power timer class for poll(). May cause missing events.",
"value": false
Expand Down