X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/d05b30e40030a14423780d6723feee75b90eaf60..1bc821059355d60e379c56083013553294df88c1:/include/wx/meta/movable.h?ds=sidebyside diff --git a/include/wx/meta/movable.h b/include/wx/meta/movable.h index 7fc60d0bbf..3583c98a59 100644 --- a/include/wx/meta/movable.h +++ b/include/wx/meta/movable.h @@ -14,6 +14,17 @@ #include "wx/defs.h" #include "wx/string.h" // for wxIsMovable specialization +// This macro declares something called "value" inside a class declaration. +// +// It has to be used because VC6 doesn't handle initialization of the static +// variables in the class declaration itself while BCC5.82 doesn't understand +// enums (it compiles the template fine but can't use it later) +#if defined(__VISUALC__) && !wxCHECK_VISUALC_VERSION(7) + #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) enum { value = val } +#else + #define wxDEFINE_TEMPLATE_BOOL_VALUE(val) static const bool value = val +#endif + // Helper to decide if an object of type T is "movable", i.e. if it can be // copied to another memory location using memmove() or realloc() C functions. // C++ only gurantees that POD types (including primitive types) are @@ -21,8 +32,7 @@ template struct wxIsMovable { - // NB: enum, because VC6 can't handle "static const bool value = true;" - enum { value = false }; + wxDEFINE_TEMPLATE_BOOL_VALUE(false); }; // Macro to add wxIsMovable specialization for given type that marks it @@ -30,7 +40,7 @@ struct wxIsMovable #define WX_DECLARE_TYPE_MOVABLE(type) \ template<> struct wxIsMovable \ { \ - enum { value = true }; \ + wxDEFINE_TEMPLATE_BOOL_VALUE(true); \ }; WX_DECLARE_TYPE_MOVABLE(bool) @@ -56,18 +66,19 @@ WX_DECLARE_TYPE_MOVABLE(wxULongLong_t) // Visual C++ 6.0 can't compile partial template specializations and as this is // only an optimization, we can live with pointers not being recognized as // movable types under VC6 -#if !wxCHECK_VISUALC_VERSION(7) +#if !defined(__VISUALC__) || wxCHECK_VISUALC_VERSION(7) // pointers are movable: template struct wxIsMovable { - enum { value = true }; + static const bool value = true; }; + template struct wxIsMovable { - enum { value = true }; + static const bool value = true; }; #endif // !VC++ < 7 @@ -81,5 +92,4 @@ struct wxIsMovable WX_DECLARE_TYPE_MOVABLE(wxString) #endif - #endif // _WX_META_MOVABLE_H_