diff options
author | Underground78 <underground78@users.sourceforge.net> | 2016-01-14 01:02:03 +0300 |
---|---|---|
committer | Underground78 <underground78@users.sourceforge.net> | 2016-01-19 23:52:26 +0300 |
commit | daf758ab2f256937d0583c5db77d298f14163a33 (patch) | |
tree | 8c5e9a21d85b36e50ceddd1a6dbd53c5cd3c6b16 | |
parent | a6bd02a43bc83ac081e833ee67d8366ebf398a39 (diff) |
Remove invalid string conversion operators.
Cast to std::string does not work for VS2013 and VS2015 and cast to string reference must not be used because they point to temporary variables.
-rw-r--r-- | timxmlrpc.h | 26 |
1 files changed, 4 insertions, 22 deletions
diff --git a/timxmlrpc.h b/timxmlrpc.h index 8b70bf0..96f9fd9 100644 --- a/timxmlrpc.h +++ b/timxmlrpc.h @@ -178,31 +178,16 @@ public: bool operator==(XmlRpcValue const& other) const; bool operator!=(XmlRpcValue const& other) const { return !(*this == other); } - // This is an alternative to operator std::string() that Aigner claims is needed for VS13 std::string GetStdString() { if (_type == TypeInt) { - char tmp[80]; - _itoa_s(u.asInt, tmp, 10); // itoa(u.asInt, tmp, 10); - return (std::string)tmp; + char tmp[16]; + _itoa_s(u.asInt, tmp, 10); + return tmp; } assertTypeOrInvalid(TypeString); - return std::string(u.asString); + return u.asString; } -#if defined(_MSC_VER) && (_MSC_VER > 1700) - operator const std::string& () { - if (_type == TypeInt) { - char tmp[80]; - _itoa_s(u.asInt, tmp, 10); // itoa(u.asInt, tmp, 10); - return std::move(std::string(tmp)); - } - assertTypeOrInvalid(TypeString); - return std::move(std::string(u.asString)); - } -#else - operator std::string () { return GetStdString(); } -#endif - // There are some basic type conversions here. This might mean that your // program parses stuff that strictly speaking it should report as a type error. @@ -227,9 +212,6 @@ public: assertTypeOrInvalid(TypeDouble); return 0; } - operator std::string&() { - return GetStdString(); - } operator const char*() { assertTypeOrInvalid(TypeString); return u.asString; } operator BinaryData&() { assertTypeOrInvalid(TypeBase64); return *u.asBinary; } |