Jelajahi Sumber

feat(string): add operator==

greatbridf 2 tahun lalu
induk
melakukan
6bab50c7fe
1 mengubah file dengan 4 tambahan dan 0 penghapusan
  1. 4 0
      include/types/string.hpp

+ 4 - 0
include/types/string.hpp

@@ -73,6 +73,10 @@ public:
     {
     {
         return this->append(move(str));
         return this->append(move(str));
     }
     }
+    bool operator==(const string& rhs) const
+    {
+        return strcmp(c_str(), rhs.c_str()) == 0;
+    }
     string substr(size_type pos, size_type n = npos)
     string substr(size_type pos, size_type n = npos)
     {
     {
         return string(this->m_arr + pos, n);
         return string(this->m_arr + pos, n);