diff --git a/include/wx/any.h b/include/wx/any.h index e20ab0e78d..91b1abf0f9 100644 --- a/include/wx/any.h +++ b/include/wx/any.h @@ -679,11 +679,19 @@ public: /** Various constructors. */ + template + wxAny(const T& value) + { + m_type = wxAnyValueTypeImpl::sm_instance; + wxAnyValueTypeImpl::SetValue(value, m_buffer); + } + wxAny(const char* value) { m_type = wxAnyNullValueType; Assign(wxString(value)); } + wxAny(const wchar_t* value) { m_type = wxAnyNullValueType; @@ -697,6 +705,7 @@ public: } #if wxUSE_VARIANT + template<> wxAny(const wxVariant& variant) { m_type = wxAnyNullValueType; @@ -704,12 +713,6 @@ public: } #endif - template - wxAny(const T& value) - { - m_type = wxAnyValueTypeImpl::sm_instance; - wxAnyValueTypeImpl::SetValue(value, m_buffer); - } //@} /** @@ -914,6 +917,7 @@ public: #if wxUSE_VARIANT // GetAs() wxVariant specialization + template<> bool GetAs(wxVariant* value) const { return wxConvertAnyToVariant(*this, value); diff --git a/src/common/variant.cpp b/src/common/variant.cpp index 86c60ec187..57aba64bb1 100644 --- a/src/common/variant.cpp +++ b/src/common/variant.cpp @@ -224,15 +224,15 @@ wxAny wxVariant::GetAny() const wxAny any; if ( IsNull() ) - return wxAny((const wxAny&)any); + return any; wxVariantData* data = GetData(); if ( data->GetAsAny(&any) ) - return wxAny((const wxAny&)any); + return any; // If everything else fails, wrap the whole wxVariantData - return wxAny(((wxVariantData*)data)); + return wxAny(data); } #endif // wxUSE_ANY