remove Var::operator const std::string & ()

This commit is contained in:
Aleksandar Fabijanic
2012-09-25 23:50:15 +00:00
parent 0c05ec4701
commit e7ee78baa5
3 changed files with 3 additions and 21 deletions

View File

@@ -190,11 +190,6 @@ public:
}
}
operator const std::string & ();
/// Specialization of the cast operator for const std::string reference.
/// The main reason for this specialization is to help compilers
/// with construction/assignment of Var to std::string.
template <typename T>
const T& extract() const
/// Returns a const reference to the actual value.

View File

@@ -69,15 +69,6 @@ Var::~Var()
}
Var::operator const std::string & ()
{
if (typeid(std::string) != _pHolder->type())
*this = this->convert<std::string>();
return extract<std::string>();
}
Var& Var::operator = (const Var& other)
{
Var tmp(other);

View File

@@ -1406,18 +1406,14 @@ void VarTest::testConversionOperator()
assert (any == i);
any = 123;
#ifdef _MSC_VER
std::string s1(any);
#else // gcc won't compile above (ambiguous cctor call)
std::string s1 = any;
#endif
std::string s1 = any.convert<std::string>();
assert (s1 == "123");
assert (s1 == any);
assert (any == s1);
assert ("123" == any);
any = 321;
s1 =any.convert<std::string>();
s1 = any.convert<std::string>();
assert (s1 == "321");
any = "456";
@@ -1425,7 +1421,7 @@ void VarTest::testConversionOperator()
assert ("456" == any);
any = 789;
std::string s2 = any;
std::string s2 = any.convert<std::string>();
assert (s2 == "789");
assert (s2 == any);
assert (any == s2);