== operator & tests

This commit is contained in:
Aleksandar Fabijanic 2007-04-26 09:27:21 +00:00
parent 4cf5e8ac12
commit 671fd27d12
2 changed files with 24 additions and 0 deletions

View File

@ -171,6 +171,23 @@ public:
return *this;
}
template <typename T>
bool operator == (const T& other)
/// Equality operator
{
T result;
_pHolder->convert(result);
return result == other;
}
bool operator == (const char* other)
/// Equality operator
{
std::string result;
_pHolder->convert(result);
return result == other;
}
const std::type_info& type() const;
/// Returns the type information of the stored content.

View File

@ -1120,6 +1120,13 @@ void DynamicAnyTest::testConversionOperator()
any = 123;
std::string s = any;//'s(any)' bombs on gcc 3.4.4
assert (s == "123");
any = 321;
s = (std::string) any;//must cast to disambiguate char/string
assert (s == "321");
any = "456";
assert (any == "456");
}