]> git.saurik.com Git - wxWidgets.git/blame - include/wx/checkeddelete.h
Use wxGetTranslation() instead of _() in the public headers.
[wxWidgets.git] / include / wx / checkeddelete.h
CommitLineData
664e1314
VZ
1///////////////////////////////////////////////////////////////////////////////
2// Name: wx/checkeddelete.h
3// Purpose: wxCHECKED_DELETE() macro
4// Author: Vadim Zeitlin
5// Created: 2009-02-03
664e1314
VZ
6// Copyright: (c) 2002-2009 wxWidgets dev team
7// Licence: wxWindows licence
8///////////////////////////////////////////////////////////////////////////////
9
10#ifndef _WX_CHECKEDDELETE_H_
11#define _WX_CHECKEDDELETE_H_
12
4d3845c0
VZ
13#include "wx/cpp.h"
14
664e1314
VZ
15// TODO: provide wxCheckedDelete[Array]() template functions too
16
17// ----------------------------------------------------------------------------
18// wxCHECKED_DELETE and wxCHECKED_DELETE_ARRAY macros
19// ----------------------------------------------------------------------------
20
21/*
22 checked deleters are used to make sure that the type being deleted is really
23 a complete type.: otherwise sizeof() would result in a compile-time error
24
25 do { ... } while ( 0 ) construct is used to have an anonymous scope
26 (otherwise we could have name clashes between different "complete"s) but
27 still force a semicolon after the macro
28*/
29
664e1314 30#define wxCHECKED_DELETE(ptr) \
4d3845c0 31 wxSTATEMENT_MACRO_BEGIN \
540dacb6 32 typedef char complete[sizeof(*ptr)] WX_ATTRIBUTE_UNUSED; \
664e1314 33 delete ptr; \
4d3845c0 34 wxSTATEMENT_MACRO_END
664e1314
VZ
35
36#define wxCHECKED_DELETE_ARRAY(ptr) \
4d3845c0 37 wxSTATEMENT_MACRO_BEGIN \
540dacb6 38 typedef char complete[sizeof(*ptr)] WX_ATTRIBUTE_UNUSED; \
664e1314 39 delete [] ptr; \
4d3845c0 40 wxSTATEMENT_MACRO_END
664e1314
VZ
41
42
43#endif // _WX_CHECKEDDELETE_H_
44