]> git.saurik.com Git - wxWidgets.git/blame - include/wx/meta/movable.h
Remove unnecessary IsRadioButton().
[wxWidgets.git] / include / wx / meta / movable.h
CommitLineData
6712283c
VS
1/////////////////////////////////////////////////////////////////////////////
2// Name: wx/meta/movable.h
3// Purpose: Test if a type is movable using memmove() etc.
4// Author: Vaclav Slavik
5// Created: 2008-01-21
6// RCS-ID: $Id$
7// Copyright: (c) 2008 Vaclav Slavik
8// Licence: wxWindows licence
9/////////////////////////////////////////////////////////////////////////////
10
11#ifndef _WX_META_MOVABLE_H_
12#define _WX_META_MOVABLE_H_
13
14#include "wx/defs.h"
15#include "wx/string.h" // for wxIsMovable<wxString> specialization
16
17// Helper to decide if an object of type T is "movable", i.e. if it can be
18// copied to another memory location using memmove() or realloc() C functions.
19// C++ only gurantees that POD types (including primitive types) are
20// movable.
21template<typename T>
22struct wxIsMovable
23{
24 // NB: enum, because VC6 can't handle "static const bool value = true;"
25 enum { value = false };
26};
27
28// Macro to add wxIsMovable<T> specialization for given type that marks it
29// as movable:
30#define WX_DECLARE_TYPE_MOVABLE(type) \
31 template<> struct wxIsMovable<type> \
32 { \
33 enum { value = true }; \
34 };
35
36WX_DECLARE_TYPE_MOVABLE(bool)
37WX_DECLARE_TYPE_MOVABLE(unsigned char)
38WX_DECLARE_TYPE_MOVABLE(signed char)
39WX_DECLARE_TYPE_MOVABLE(unsigned int)
40WX_DECLARE_TYPE_MOVABLE(signed int)
41WX_DECLARE_TYPE_MOVABLE(unsigned short int)
42WX_DECLARE_TYPE_MOVABLE(signed short int)
43WX_DECLARE_TYPE_MOVABLE(signed long int)
44WX_DECLARE_TYPE_MOVABLE(unsigned long int)
45WX_DECLARE_TYPE_MOVABLE(float)
46WX_DECLARE_TYPE_MOVABLE(double)
47WX_DECLARE_TYPE_MOVABLE(long double)
48#if wxWCHAR_T_IS_REAL_TYPE
49WX_DECLARE_TYPE_MOVABLE(wchar_t)
50#endif
51#ifdef wxLongLong_t
52WX_DECLARE_TYPE_MOVABLE(wxLongLong_t)
53WX_DECLARE_TYPE_MOVABLE(wxULongLong_t)
54#endif
55
56// pointers are movable:
57template<typename T>
58struct wxIsMovable<T*>
59{
60 enum { value = true };
61};
62template<typename T>
63struct wxIsMovable<const T*>
64{
65 enum { value = true };
66};
67
68// Our implementation of wxString is written in such way that it's safe to move
69// it around. OTOH, we don't know anything about std::string.
70// (NB: we don't put this into string.h and choose to include wx/string.h from
71// here instead so that rarely-used wxIsMovable<T> code isn't included by
72// everything)
73#if !wxUSE_STL
74WX_DECLARE_TYPE_MOVABLE(wxString)
75#endif
76
77
78#endif // _WX_META_MOVABLE_H_