浏览代码

String: Define operator>(String)

Andreas Kling 5 年之前
父节点
当前提交
96f9e6a64f
共有 1 个文件被更改,包括 11 次插入0 次删除
  1. 11 0
      AK/String.cpp

+ 11 - 0
AK/String.cpp

@@ -44,6 +44,17 @@ bool String::operator<(const String& other) const
     return strcmp(characters(), other.characters()) < 0;
 }
 
+bool String::operator>(const String& other) const
+{
+    if (!m_impl)
+        return other.m_impl;
+
+    if (!other.m_impl)
+        return false;
+
+    return strcmp(characters(), other.characters()) > 0;
+}
+
 String String::empty()
 {
     return StringImpl::the_empty_stringimpl();