mirror of
https://github.com/zeek/zeek.git
synced 2025-10-09 10:08:20 +00:00
Add cast_intrusive() and make use of it in two spots
This commit is contained in:
parent
c6f2e35af0
commit
6a1e4d61d1
3 changed files with 18 additions and 6 deletions
|
@ -184,6 +184,18 @@ IntrusivePtr<T> make_intrusive(Ts&&... args)
|
|||
return {AdoptRef{}, new T(std::forward<Ts>(args)...)};
|
||||
}
|
||||
|
||||
/**
|
||||
* Casts an @c IntrusivePtr object to another by way of static_cast on
|
||||
* the underlying pointer.
|
||||
* @param p The pointer of type @c U to cast to another type, @c T.
|
||||
* @return The pointer, as cast to type @c T.
|
||||
*/
|
||||
template <class T, class U>
|
||||
IntrusivePtr<T> cast_intrusive(IntrusivePtr<U> p) noexcept
|
||||
{
|
||||
return {AdoptRef{}, static_cast<T*>(p.release())};
|
||||
}
|
||||
|
||||
// -- comparison to nullptr ----------------------------------------------------
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue