From 706068e4011b42dd98a0ec8306cfac684712c802 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Fri, 8 Aug 2008 02:35:56 +0000 Subject: [PATCH] document DECLARE_NO_{COPY,ASSIGN}_CLASS git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@55017 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- interface/wx/defs.h | 50 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/interface/wx/defs.h b/interface/wx/defs.h index 61b05d3599..b1b2c9536e 100644 --- a/interface/wx/defs.h +++ b/interface/wx/defs.h @@ -1,5 +1,5 @@ ///////////////////////////////////////////////////////////////////////////// -// Name: defs.h +// Name: wx/defs.h // Purpose: interface of global functions // Author: wxWidgets team // RCS-ID: $Id$ @@ -8,7 +8,7 @@ /** Item kinds for use with wxMenu, wxMenuItem, and wxToolBar. - + @see wxMenu::Append(), wxMenuItem::wxMenuItem(), wxToolBar::AddTool() */ enum wxItemKind @@ -244,6 +244,52 @@ enum wxPaperSize /** @ingroup group_funcmacro_misc */ //@{ +/** + This macro can be used in a class declaration to disable the generation of + default assignment operator. + + Some classes have a well-defined copy constructor but cannot have an + assignment operator, typically because they can't be modified once created. + In such case, this macro can be used to disable the automatic assignment + operator generation. + + @see DECLARE_NO_COPY_CLASS() + */ +#define DECLARE_NO_ASSIGN_CLASS(classname) + +/** + This macro can be used in a class declaration to disable the generation of + default copy ctor and assignment operator. + + Some classes don't have a well-defined copying semantics. In this case the + standard C++ convention is to not allow copying them. One way of achieving + it is to use this macro which simply defines a private copy constructor and + assignment operator. + + Beware that simply not defining copy constructor and assignment operator is + @em not enough as the compiler would provide its own automatically-generated + versions of them -- hence the usefulness of this macro. + + Example of use: + @code + class FooWidget + { + public: + FooWidget(); + ... + + private: + // widgets can't be copied + DECLARE_NO_COPY_CLASS(FooWidget) + }; + @endcode + + Notice that a semicolon should not be used after this macro and that it + changes the access specifier to private internally so it is better to use + it at the end of the class declaration. + */ +#define DECLARE_NO_COPY_CLASS(classname) + /** This macro can be used around a function declaration to generate warnings indicating that this function is deprecated (i.e. obsolete and planned to -- 2.45.2