Files
XCSDD/docs/api/containers/string/operator-equal.md
ssdfasd 58a83f445a fix: improve doc link navigation and tree display
- Fix link resolution with proper relative/absolute path handling
- Improve link styling with underline decoration
- Hide leaf nodes from tree, only show directories
- Fix log file path for packaged app
2026-03-19 12:44:08 +08:00

1.0 KiB
Raw Blame History

operator== / operator!=

inline bool operator==(const String& lhs, const String& rhs);
inline bool operator!=(const String& lhs, const String& rhs);

判断两个字符串是否相等或不相等。

operator== 比较两个字符串的长度是否相等,以及内容是否相同。

operator!= 相当于 !(lhs == rhs)

参数:

  • lhs - 左侧字符串
  • rhs - 右侧字符串

返回: 布尔值,表示比较结果

复杂度: O(n),其中 n 为字符串长度

示例:

#include "XCEngine/Containers/String.h"
#include <iostream>

int main() {
    XCEngine::Containers::String s1("Hello");
    XCEngine::Containers::String s2("Hello");
    XCEngine::Containers::String s3("World");

    std::cout << std::boolalpha;
    std::cout << (s1 == s2) << std::endl;  // 输出: true
    std::cout << (s1 == s3) << std::endl;  // 输出: false
    std::cout << (s1 != s3) << std::endl;  // 输出: true

    return 0;
}

相关文档