[config] New NO_COPYABLE, DELETE_COPY_CTOR and DELETE_COPY_ASSIGN macros

Hi, I'm using the following BOOST_NO_COPYABLE, BOOST_DELETE_COPY_CTOR, BOOST_DELETE_COPY_ASSIGN and macros in Boost.Thread (see http://svn.boost.org/svn/boost/trunk/boost/thread/detail/delete.hpp). I guess some of you have their own similar macros. For uniformity purposes, couldn't them be added to Boost.Config/ Boost Helper Macros <cid:part1.09000208.02050709@wanadoo.fr> if I provide a patch with doc and tests? Best, Vicente [section:delete `=delete` emulation] C++11 allows to delete some implicitly generated functions as constructors and assignment using '= delete' as in public: CLASS(CLASS const&) = delete; CLASS& operator=(CLASS const&) = delete; On compilers not supporting this feature, we can relays on a partial simulation, by declaring the function as private without definition. private: CLASS(CLASS &); CLASS& operator=(CLASS&); The emulation is good but partial as the private functions are still visible. To have the best the user should write public: #ifndef BOOST_NO_DELETED_FUNCTIONS CLASS(CLASS const&) = delete; CLASS& operator=(CLASS const&) = delete; #else // BOOST_NO_DELETED_FUNCTIONS private: CLASS(CLASS&); CLASS& operator=(CLASS&); public: #endif // BOOST_NO_DELETED_FUNCTIONS The following macros allows to take in account the features the compiler provides and have the same effect public: BOOST_DELETE_COPY_CTOR(CLASS) BOOST_DELETE_COPY_ASSIGN(CLASS) As these come together quite often when we want to make a non copyable class the user can use instead public: BOOST_NO_COPYABLE(CLASS) [section:delete_copy_ctor `BOOST_DELETE_COPY_CTOR(CLASS)`] This macro deletes the copy constructor when the compiler supports it or makes it private. It can be included on the public section only. [endsect] [section:delete_copy_assign `BOOST_DELETE_COPY_ASSIGN(CLASS)`] This macro deletes the copy assignment when the compiler supports it or makes it private. It can be included on the public section only. [endsect] [section:no_copyable `BOOST_NO_COPYABLE(CLASS)`] This macro makes a class as no copyable, disabling copy construction and assignment. It can be included on the public section only. [endsect] [endsect]

On Tue, May 1, 2012 at 9:50 AM, Vicente J. Botet Escriba <vicente.botet@wanadoo.fr> wrote:
As these come together quite often when we want to make a non copyable class the user can use instead
public: BOOST_NO_COPYABLE(CLASS)
Isn't it simpler to derive from boost::noncopyable? Olaf

Olaf van der Spek-3 wrote
On Tue, May 1, 2012 at 9:50 AM, Vicente J. Botet Escriba <vicente.botet@> wrote:
As these come together quite often when we want to make a non copyable class the user can use instead
public: BOOST_NO_COPYABLE(CLASS)
Isn't it simpler to derive from boost::noncopyable?
Hi, I want to avoid to derive from whatever class. Best, Vicente -- View this message in context: http://boost.2283326.n4.nabble.com/config-New-NO-COPYABLE-DELETE-COPY-CTOR-a... Sent from the Boost - Dev mailing list archive at Nabble.com.

On Fri, May 11, 2012 at 3:58 PM, Vicente Botet <vicente.botet@wanadoo.fr> wrote:
Olaf van der Spek-3 wrote
On Tue, May 1, 2012 at 9:50 AM, Vicente J. Botet Escriba <vicente.botet@> wrote:
As these come together quite often when we want to make a non copyable class the user can use instead
public: BOOST_NO_COPYABLE(CLASS)
Isn't it simpler to derive from boost::noncopyable?
Hi,
I want to avoid to derive from whatever class.
Why? -- Olaf
participants (3)
-
Olaf van der Spek
-
Vicente Botet
-
Vicente J. Botet Escriba