mirror of https://github.com/ARMmbed/mbed-os.git
commit
0699ac4e7e
|
@ -91,18 +91,16 @@ namespace mbed {
|
||||||
* in the base declaration.
|
* in the base declaration.
|
||||||
*
|
*
|
||||||
* To solve that problem, the copy constructor and assignment operator have to
|
* To solve that problem, the copy constructor and assignment operator have to
|
||||||
* be declared (but don't need to be defined) in the private section of the
|
* be defined as deleted:
|
||||||
* Connection class:
|
|
||||||
*
|
*
|
||||||
* @code
|
* @code
|
||||||
* struct Connection {
|
* struct Connection {
|
||||||
* private:
|
* Connection(const Connection &) = delete;
|
||||||
* Connection(const Connection&);
|
* Connection &operator=(const Connection &) = delete;
|
||||||
* Connection& operator=(const Connection&);
|
|
||||||
* }
|
* }
|
||||||
* @endcode
|
* @endcode
|
||||||
*
|
*
|
||||||
* Although manually declaring private copy constructor and assignment functions
|
* Although manually defining deleted copy constructor and assignment functions
|
||||||
* works, it is not ideal. These declarations are usually easy to forget,
|
* works, it is not ideal. These declarations are usually easy to forget,
|
||||||
* not immediately visible, and may be obscure to uninformed programmers.
|
* not immediately visible, and may be obscure to uninformed programmers.
|
||||||
*
|
*
|
||||||
|
@ -211,18 +209,18 @@ protected:
|
||||||
}
|
}
|
||||||
|
|
||||||
#else
|
#else
|
||||||
private:
|
public:
|
||||||
/**
|
/**
|
||||||
* Declare copy constructor as private. Any attempt to copy construct
|
* Define copy constructor as deleted. Any attempt to copy construct
|
||||||
* a NonCopyable will fail at compile time.
|
* a NonCopyable will fail at compile time.
|
||||||
*/
|
*/
|
||||||
NonCopyable(const NonCopyable &);
|
NonCopyable(const NonCopyable &) = delete;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Declare copy assignment operator as private. Any attempt to copy assign
|
* Define copy assignment operator as deleted. Any attempt to copy assign
|
||||||
* a NonCopyable will fail at compile time.
|
* a NonCopyable will fail at compile time.
|
||||||
*/
|
*/
|
||||||
NonCopyable &operator=(const NonCopyable &);
|
NonCopyable &operator=(const NonCopyable &) = delete;
|
||||||
#endif
|
#endif
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in New Issue