#include "wx/defs.h"
#include "wx/string.h" // for wxIsMovable<wxString> 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
template<typename T>
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<T> specialization for given type that marks it
#define WX_DECLARE_TYPE_MOVABLE(type) \
template<> struct wxIsMovable<type> \
{ \
- enum { value = true }; \
+ wxDEFINE_TEMPLATE_BOOL_VALUE(true); \
};
WX_DECLARE_TYPE_MOVABLE(bool)
template<typename T>
struct wxIsMovable<T*>
{
- enum { value = true };
+ static const bool value = true;
};
+
template<typename T>
struct wxIsMovable<const T*>
{
- enum { value = true };
+ static const bool value = true;
};
#endif // !VC++ < 7
// Our implementation of wxString is written in such way that it's safe to move
-// it around. OTOH, we don't know anything about std::string.
+// it around (unless position cache is used which unfortunately breaks this).
+// OTOH, we don't know anything about std::string.
// (NB: we don't put this into string.h and choose to include wx/string.h from
// here instead so that rarely-used wxIsMovable<T> code isn't included by
// everything)
-#if !wxUSE_STL
+#if !wxUSE_STL && !wxUSE_STRING_POS_CACHE
WX_DECLARE_TYPE_MOVABLE(wxString)
#endif
-
#endif // _WX_META_MOVABLE_H_