7 #ifndef RETDEC_LLVMIR2HLL_SUPPORT_SMART_PTR_H
8 #define RETDEC_LLVMIR2HLL_SUPPORT_SMART_PTR_H
18 using ShPtr = std::shared_ptr<T>;
26 using UPtr = std::unique_ptr<T>;
43 template<
class ForClass>
48 using std::enable_shared_from_this<ForClass>::shared_from_this;
62 template<
typename To,
typename From>
64 return std::dynamic_pointer_cast<To>(ptr);
81 template<
typename To,
typename From>
83 return std::static_pointer_cast<To>(ptr);
107 template<
typename To,
typename From>
109 return cast<To>(ptr) !=
nullptr;
121 return ptr.lock() == otherPtr.lock();
Enables shared_from_this() in the inheriting class.
Definition: smart_ptr.h:44
A predicate for checking the equality of two weak pointers.
Definition: smart_ptr.h:116
WkPtrEqPredicate(const WkPtr< T > &ptr)
Definition: smart_ptr.h:118
bool operator()(const WkPtr< T > &otherPtr) const
Definition: smart_ptr.h:120
const WkPtr< T > & ptr
Definition: smart_ptr.h:125
A library providing API for working with back-end IR.
std::weak_ptr< T > WkPtr
An alias for a weak pointer.
Definition: smart_ptr.h:22
std::shared_ptr< T > ShPtr
An alias for a shared pointer.
Definition: smart_ptr.h:18
std::unique_ptr< T > UPtr
An alias for a unique pointer.
Definition: smart_ptr.h:26
ShPtr< To > cast(const ShPtr< From > &ptr) noexcept
Equivalent of dynamic_cast<> for shared pointers.
Definition: smart_ptr.h:63
ShPtr< To > ucast(const ShPtr< From > &ptr) noexcept
Equivalent of static_cast<> for shared pointers (unchecked cast).
Definition: smart_ptr.h:82
bool isa(const ShPtr< From > &ptr) noexcept
Returns true if ptr is of type To or can be casted from From to To, false otherwise.
Definition: smart_ptr.h:108
Definition: archive_wrapper.h:19