Fix VC6 compilation by changing the order of assignment operators in wxAny

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@64059 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Jaakko Salli
2010-04-20 12:55:34 +00:00
parent b871bb951a
commit 49efebe247
2 changed files with 18 additions and 32 deletions

View File

@@ -765,32 +765,6 @@ public:
/** /**
Assignment operators. Assignment operators.
*/ */
wxAny& operator=(const wxAny &any)
{
if (this != &any)
AssignAny(any);
return *this;
}
#if wxUSE_VARIANT && (!defined(__VISUALC__) || __VISUALC__ >= 1300)
//
// Adding this operator for VC6 breaks wxAny, and also
// some cases of implicit conversion from wxVariant to wxAny.
//
// e.g. wxAny any = variant; // should work
//
// wxAny any;
// any = 16;
// any = variant; // probably doesn't work - uses template
// // assignment, most likely
//
wxAny& operator=(const wxVariant &variant)
{
AssignVariant(variant);
return *this;
}
#endif
template<typename T> template<typename T>
wxAny& operator=(const T &value) wxAny& operator=(const T &value)
{ {
@@ -800,6 +774,21 @@ public:
return *this; return *this;
} }
wxAny& operator=(const wxAny &any)
{
if (this != &any)
AssignAny(any);
return *this;
}
#if wxUSE_VARIANT
wxAny& operator=(const wxVariant &variant)
{
AssignVariant(variant);
return *this;
}
#endif
wxAny& operator=(const char* value) wxAny& operator=(const char* value)
{ Assign(wxString(value)); return *this; } { Assign(wxString(value)); return *this; }
wxAny& operator=(const wchar_t* value) wxAny& operator=(const wchar_t* value)

View File

@@ -482,16 +482,13 @@ void wxAnyTestCase::wxVariantConversions()
CPPUNIT_ASSERT(variant.GetType() == "ulonglong"); CPPUNIT_ASSERT(variant.GetType() == "ulonglong");
CPPUNIT_ASSERT(variant.GetLong() == 1000); CPPUNIT_ASSERT(variant.GetLong() == 1000);
// FIXME-VC6: for VC6, any = variant needs to be any = wxAny(variant). any = vString;
// Note that 'wxAny any = variant' does work, probably because
// ctor is used in that case instead of assignment operator.
any = wxAny(vString);
CPPUNIT_ASSERT(any == "ABC"); CPPUNIT_ASSERT(any == "ABC");
res = any.GetAs(&variant); res = any.GetAs(&variant);
CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(res);
CPPUNIT_ASSERT(variant.GetString() == "ABC"); CPPUNIT_ASSERT(variant.GetString() == "ABC");
any = wxAny(vDouble); any = vDouble;
double d = wxANY_AS(any, double); double d = wxANY_AS(any, double);
CPPUNIT_ASSERT_DOUBLES_EQUAL(d, TEST_FLOAT_CONST, FEQ_DELTA); CPPUNIT_ASSERT_DOUBLES_EQUAL(d, TEST_FLOAT_CONST, FEQ_DELTA);
res = any.GetAs(&variant); res = any.GetAs(&variant);
@@ -500,7 +497,7 @@ void wxAnyTestCase::wxVariantConversions()
TEST_FLOAT_CONST, TEST_FLOAT_CONST,
FEQ_DELTA); FEQ_DELTA);
any = wxAny(vBool); any = vBool;
CPPUNIT_ASSERT(wxANY_AS(any, bool) == true); CPPUNIT_ASSERT(wxANY_AS(any, bool) == true);
res = any.GetAs(&variant); res = any.GetAs(&variant);
CPPUNIT_ASSERT(res); CPPUNIT_ASSERT(res);