Skip to content

Commit

Permalink
Merge pull request #289 from BeyondWUXF/feature/BeyondWUXF/AutoPtr_st…
Browse files Browse the repository at this point in the history
…aticCast

add staticCast
  • Loading branch information
ruanshudong authored Sep 27, 2023
2 parents 3fa4470 + 6b51019 commit cf81155
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions util/include/util/tc_autoptr.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,6 +339,34 @@ class TC_AutoPtr
return TC_AutoPtr(dynamic_cast<T*>(p));
}

/**
* @brief Replace other types of smart pointers with current types of smart pointers
* @brief 将其他类型的智能指针换成当前类型的智能指针.
*
* @param Y
* @param r
* @return TC_AutoPtr
*/
template<class Y>
static TC_AutoPtr staticCast(const TC_AutoPtr<Y>& r)
{
return TC_AutoPtr(static_cast<T*>(r._ptr));
}

/**
* @brief Convert pointers of other native types into smart pointers of the current type
* @brief 将其他原生类型的指针转换成当前类型的智能指针.
*
* @param Y
* @param p
* @return TC_AutoPtr
*/
template<class Y>
static TC_AutoPtr staticCast(Y* p)
{
return TC_AutoPtr(static_cast<T*>(p));
}

/**
* @brief Get Native Pointer
* @brief 获取原生指针.
Expand Down

0 comments on commit cf81155

Please sign in to comment.