docs: 重构 API 文档结构并修正源码准确性
- 重组文档目录结构: 每个模块的概述页移动到模块子目录 - 重命名 index.md 为 main.md - 修正所有模块文档中的错误: - math: FromEuler→FromEulerAngles, TransformDirection 包含缩放, Box 是 OBB, Color::ToRGBA 格式 - containers: 新增 operator==/!= 文档, 补充 std::hash DJB 算法细节 - core: 修复 types 链接错误 - debug: LogLevelToString 返回大写, timestamp 是秒, Profiler 空实现标注, Windows API vs ANSI - memory: 修复头文件路径, malloc vs operator new, 新增方法文档 - resources: 修复 Shader/Texture 链接错误 - threading: TaskSystem::Wait 空实现标注, ReadWriteLock 重入描述, LambdaTask 链接 - 验证: fix_links.py 确认 0 个断裂引用
This commit is contained in:
47
docs/api/containers/string/operator-assign.md
Normal file
47
docs/api/containers/string/operator-assign.md
Normal file
@@ -0,0 +1,47 @@
|
||||
# String::operator=
|
||||
|
||||
```cpp
|
||||
String& operator=(const String& other);
|
||||
String& operator=(String&& other) noexcept;
|
||||
String& operator=(const char* str);
|
||||
```
|
||||
|
||||
将新的值赋给 String 对象,替换原有的内容。
|
||||
|
||||
**参数:**
|
||||
- `other` - 另一个 String 对象(拷贝赋值或移动赋值)
|
||||
- `str` - 以 null 结尾的 C 字符串
|
||||
|
||||
**返回:** `*this`,支持链式调用
|
||||
|
||||
**复杂度:**
|
||||
- 拷贝赋值:O(n),n 为 other 的长度
|
||||
- 移动赋值:O(1)
|
||||
- 从 `const char*` 赋值:O(n),n 为 str 的长度
|
||||
|
||||
**示例:**
|
||||
```cpp
|
||||
#include "XCEngine/Containers/String.h"
|
||||
#include <iostream>
|
||||
|
||||
int main() {
|
||||
XCEngine::Containers::String s1;
|
||||
XCEngine::Containers::String s2("hello");
|
||||
|
||||
s1 = s2; // 拷贝赋值
|
||||
std::cout << s1.CStr() << std::endl; // 输出: hello
|
||||
|
||||
s1 = "world"; // 从 const char* 赋值
|
||||
std::cout << s1.CStr() << std::endl; // 输出: world
|
||||
|
||||
XCEngine::Containers::String s3("moved");
|
||||
s1 = std::move(s3); // 移动赋值
|
||||
std::cout << s1.CStr() << std::endl; // 输出: moved
|
||||
|
||||
return 0;
|
||||
}
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [String 总览](string.md) - 返回类总览
|
||||
Reference in New Issue
Block a user