Files
XCEngine/docs/api/containers/string/operator-equal.md
ssdfasd 5c3566774b docs: 更新 containers 和 threading 模块文档
- containers: 更新 string 类的多个方法文档
- threading: 更新 mutex 和 task-group 方法文档
2026-03-26 01:59:14 +08:00

44 lines
1.0 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# operator== / operator!=
```cpp
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 为字符串长度
**示例:**
```cpp
#include "XCEngine/Core/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;
}
```
## 相关文档
- [String 总览](string.md) - 返回类总览