mirror of
https://github.com/pocoproject/poco.git
synced 2025-10-30 13:47:10 +01:00
remove Var::operator const std::string & ()
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user