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
This commit is contained in:
51
docs/api/core/smartptr/MakeRef.md
Normal file
51
docs/api/core/smartptr/MakeRef.md
Normal file
@@ -0,0 +1,51 @@
|
||||
# SmartPtr::MakeRef
|
||||
|
||||
```cpp
|
||||
template<typename T, typename... Args>
|
||||
Ref<T> MakeRef(Args&&... args);
|
||||
```
|
||||
|
||||
创建共享指针的工厂函数。
|
||||
|
||||
**描述**
|
||||
|
||||
`MakeRef` 是创建 `Ref<T>` 的工厂函数,使用完美转发将参数传递给 `T` 的构造函数。相比直接使用 `std::make_shared`,代码更简洁。
|
||||
|
||||
**模板参数:**
|
||||
- `T` - 被创建对象的类型
|
||||
- `Args` - 构造函数的参数类型
|
||||
|
||||
**参数:**
|
||||
- `args` - 转发给 T 构造函数的参数
|
||||
|
||||
**返回:** `Ref<T>` - 新创建的共享指针
|
||||
|
||||
**复杂度:** O(1)
|
||||
|
||||
**示例:**
|
||||
|
||||
```cpp
|
||||
#include <XCEngine/Core/SmartPtr.h>
|
||||
|
||||
class MyClass {
|
||||
public:
|
||||
MyClass(int a, int b) : m_a(a), m_b(b) {}
|
||||
int GetSum() const { return m_a + m_b; }
|
||||
private:
|
||||
int m_a, m_b;
|
||||
};
|
||||
|
||||
// 创建共享指针
|
||||
Core::Ref<MyClass> ref = Core::MakeRef<MyClass>(10, 20);
|
||||
printf("Sum: %d\n", ref->GetSum());
|
||||
|
||||
// 使用 lambda
|
||||
Core::Ref<std::function<void()>> callback = Core::MakeRef<std::function<void()>>([]() {
|
||||
printf("Callback invoked!\n");
|
||||
});
|
||||
```
|
||||
|
||||
## 相关文档
|
||||
|
||||
- [SmartPtr 总览](smartptr.md) - 返回类总览
|
||||
- [Ref](Ref.md) - Ref 类型说明
|
||||
Reference in New Issue
Block a user