From b5893f18c39b60feecf120dbb0db2ba2fb039929 Mon Sep 17 00:00:00 2001 From: cxl Date: Thu, 3 May 2012 09:21:21 +0000 Subject: [PATCH] Core: operator==(T, Value) is now resolving type compatibility (instead of crashing) git-svn-id: svn://ultimatepp.org/upp/trunk@4904 f0d560ea-af0d-0410-9eb7-867de7ffcac7 --- uppsrc/Core/Core.h | 6 ++++++ uppsrc/Core/Value.h | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/uppsrc/Core/Core.h b/uppsrc/Core/Core.h index ce32439ce..097196705 100644 --- a/uppsrc/Core/Core.h +++ b/uppsrc/Core/Core.h @@ -285,6 +285,12 @@ NAMESPACE_UPP #endif #endif +#ifdef flagOLD_VALUE +#ifdef SVO_VALUE +#undef SVO_VALUE +#endif +#endif + #include "OldValue.h" #include "Value.h" diff --git a/uppsrc/Core/Value.h b/uppsrc/Core/Value.h index 0963a80ac..b312f14b2 100644 --- a/uppsrc/Core/Value.h +++ b/uppsrc/Core/Value.h @@ -260,10 +260,10 @@ inline unsigned ValueGetHashValue(const T& x) { } #define VALUE_COMPARE_V(T, VT) \ -inline bool operator==(const Value& v, T x) { return (VT)v == x; } \ -inline bool operator==(T x, const Value& v) { return (VT)v == x; } \ -inline bool operator!=(const Value& v, T x) { return (VT)v != x; } \ -inline bool operator!=(T x, const Value& v) { return (VT)v != x; } \ +inline bool operator==(const Value& v, T x) { return v.Is() ? (VT)v == x : v == Value(x); } \ +inline bool operator==(T x, const Value& v) { return v.Is() ? (VT)v == x : v == Value(x); } \ +inline bool operator!=(const Value& v, T x) { return v.Is() ? (VT)v != x : v != Value(x); } \ +inline bool operator!=(T x, const Value& v) { return v.Is() ? (VT)v != x : v != Value(x); } \ #define VALUE_COMPARE(T) VALUE_COMPARE_V(T, T)