Gave cv::String appropriate += operators.
Note that since String is a reference to an immutable string, this doesn't actually change the string; it just replaces *this with a reference to the concatenated string.
This commit is contained in:
parent
c1f59c4c76
commit
fc49d33c8d
@ -364,6 +364,10 @@ public:
|
|||||||
String& operator=(const char* s);
|
String& operator=(const char* s);
|
||||||
String& operator=(char c);
|
String& operator=(char c);
|
||||||
|
|
||||||
|
String& operator+=(const String& str);
|
||||||
|
String& operator+=(const char* s);
|
||||||
|
String& operator+=(char c);
|
||||||
|
|
||||||
size_t size() const;
|
size_t size() const;
|
||||||
size_t length() const;
|
size_t length() const;
|
||||||
|
|
||||||
@ -416,6 +420,7 @@ public:
|
|||||||
String(const std::string& str);
|
String(const std::string& str);
|
||||||
String(const std::string& str, size_t pos, size_t len = npos);
|
String(const std::string& str, size_t pos, size_t len = npos);
|
||||||
String& operator=(const std::string& str);
|
String& operator=(const std::string& str);
|
||||||
|
String& operator+=(const std::string& str);
|
||||||
operator std::string() const;
|
operator std::string() const;
|
||||||
|
|
||||||
friend String operator+ (const String& lhs, const std::string& rhs);
|
friend String operator+ (const String& lhs, const std::string& rhs);
|
||||||
@ -544,6 +549,27 @@ String& String::operator=(char c)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
String& String::operator+=(const String& str)
|
||||||
|
{
|
||||||
|
*this = *this + str;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
String& String::operator+=(const char* s)
|
||||||
|
{
|
||||||
|
*this = *this + s;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
String& String::operator+=(char c)
|
||||||
|
{
|
||||||
|
*this = *this + c;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
size_t String::size() const
|
size_t String::size() const
|
||||||
{
|
{
|
||||||
|
@ -103,6 +103,13 @@ String& String::operator = (const std::string& str)
|
|||||||
return *this;
|
return *this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline
|
||||||
|
String& String::operator += (const std::string& str)
|
||||||
|
{
|
||||||
|
*this = *this + str;
|
||||||
|
return *this;
|
||||||
|
}
|
||||||
|
|
||||||
inline
|
inline
|
||||||
String::operator std::string() const
|
String::operator std::string() const
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user