mirror of https://github.com/ARMmbed/mbed-os.git
Fully enforce NonCopyable
Make NonCopyable fully operational so it gives compile errors in all build profiles.pull/12581/head
parent
dba3962f16
commit
874e36e05a
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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 */
|
||||
|
@ -176,39 +171,6 @@ protected:
|
|||
*/
|
||||
~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
|
||||
|
@ -222,7 +184,6 @@ public:
|
|||
*/
|
||||
NonCopyable &operator=(const NonCopyable &) = delete;
|
||||
#endif
|
||||
#endif
|
||||
};
|
||||
|
||||
/**@}*/
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue