Skip to content
Snippets Groups Projects
Commit b2f655e3 authored by Franck Dary's avatar Franck Dary
Browse files

Added const qualifier to operator ==

parent f06350c6
No related branches found
No related tags found
No related merge requests found
...@@ -18,9 +18,9 @@ class utf8char : public std::array<char, 4> ...@@ -18,9 +18,9 @@ class utf8char : public std::array<char, 4>
utf8char(const char * other); utf8char(const char * other);
utf8char & operator=(char other); utf8char & operator=(char other);
utf8char & operator=(const std::string & other); utf8char & operator=(const std::string & other);
bool operator==(char other); bool operator==(char other) const;
bool operator==(const std::string & other); bool operator==(const std::string & other) const;
bool operator!=(char other); bool operator!=(char other) const;
}; };
class utf8string : public std::vector<utf8char> class utf8string : public std::vector<utf8char>
...@@ -30,7 +30,7 @@ class utf8string : public std::vector<utf8char> ...@@ -30,7 +30,7 @@ class utf8string : public std::vector<utf8char>
utf8string & operator=(const std::string & other); utf8string & operator=(const std::string & other);
utf8string & operator=(const char * const other); utf8string & operator=(const char * const other);
bool operator==(const std::string & other); bool operator==(const std::string & other) const;
void replace(utf8char from, utf8char to); void replace(utf8char from, utf8char to);
}; };
......
...@@ -31,7 +31,7 @@ util::utf8char & util::utf8char::operator=(const std::string & other) ...@@ -31,7 +31,7 @@ util::utf8char & util::utf8char::operator=(const std::string & other)
return *this = splited[0]; return *this = splited[0];
} }
bool util::utf8char::operator==(const std::string & other) bool util::utf8char::operator==(const std::string & other) const
{ {
auto splited = splitAsUtf8(other); auto splited = splitAsUtf8(other);
if (splited.size() > 1) if (splited.size() > 1)
...@@ -39,12 +39,12 @@ bool util::utf8char::operator==(const std::string & other) ...@@ -39,12 +39,12 @@ bool util::utf8char::operator==(const std::string & other)
return *this == splited[0]; return *this == splited[0];
} }
bool util::utf8char::operator==(char other) bool util::utf8char::operator==(char other) const
{ {
return (*this)[0] == other && !(*this)[1] && !(*this)[2] && !(*this)[3]; return (*this)[0] == other && !(*this)[1] && !(*this)[2] && !(*this)[3];
} }
bool util::utf8char::operator!=(char other) bool util::utf8char::operator!=(char other) const
{ {
return ! (*this==other); return ! (*this==other);
} }
...@@ -63,7 +63,7 @@ util::utf8string & util::utf8string::operator=(const char * const other) ...@@ -63,7 +63,7 @@ util::utf8string & util::utf8string::operator=(const char * const other)
return operator=(std::string(other)); return operator=(std::string(other));
} }
bool util::utf8string::operator==(const std::string & other) bool util::utf8string::operator==(const std::string & other) const
{ {
if (size() != other.size()) if (size() != other.size())
return false; return false;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment