24 #ifndef PXR_BASE_TF_WEAK_PTR_H
25 #define PXR_BASE_TF_WEAK_PTR_H
40 #include <type_traits>
168 : _rawPtr(p._rawPtr), _remnant(std::move(p._remnant)) {
176 typename std::enable_if<
199 typename std::enable_if<
201 >::
type *
dummy = 0) : _rawPtr(p._rawPtr), _remnant(p._remnant)
211 _remnant = std::move(p._remnant);
222 T *_FetchPointer()
const {
228 bool _IsInvalid()
const {
229 return _remnant && !_remnant->
_IsAlive();
232 void const *_GetUniqueIdentifier()
const {
236 void _EnableExtraNotification()
const {
278 typedef typename TfRefPtr<T>::_Counter Counter;
281 if (Counter::AddRefIfNonzero(rawPtr)) {
294 #if !defined(doxygen)
307 : _remnant(wp._remnant) {
310 template <
template <
class>
class PtrTemplate,
class Type>
312 : _remnant(_GetRemnant(wpf)) {
318 _remnant = wp._remnant;
322 template <
template <
class>
class PtrTemplate,
class Type>
325 _remnant = _GetRemnant(wpf);
331 return wp._remnant == _remnant;
334 template <
template <
class>
class PtrTemplate,
class Type>
336 return _GetRemnant(wpf) == _remnant;
341 return wp._remnant != _remnant;
344 template <
template <
class>
class PtrTemplate,
class Type>
346 return _GetRemnant(wpf) != _remnant;
350 bool operator< (TfWeakPtr<U>
const& wp) {
351 return wp._remnant < _remnant;
354 template <
template <
class>
class PtrTemplate,
class Type>
355 bool operator< (TfWeakPtrFacade<PtrTemplate, Type>
const& wpf) {
356 return _GetRemnant(wpf) < _remnant;
362 return (_remnant && _remnant->
_IsAlive())
363 ? &TfWeakPtr::_remnant :
nullptr;
371 return _remnant && !_remnant->
_IsAlive();
375 template <
template <
class>
class PtrTemplate,
class Type>
413 using _SignatureOf__GetTfWeakBase__ =
TfWeakBase const & (U::*)()
const;
416 static std::true_type
417 _HasSig(_SignatureOf__GetTfWeakBase__<U>);
420 static decltype(_HasSig(&U::__GetTfWeakBase__))
423 static std::false_type
427 using type = decltype(_Deduce(static_cast<T*>(
nullptr)));
439 #define TF_SUPPORTS_WEAKPTR(T) (Tf_SupportsWeakPtr<T>::value)
440 #define TF_TRULY_SUPPORTS_WEAKPTR(T) std::is_base_of<TfWeakBase, T >::value
442 #define TF_DECLARE_WEAK_POINTABLE_INTERFACE \
443 virtual TfWeakBase const &__GetTfWeakBase__() const = 0
445 #define TF_IMPLEMENT_WEAK_POINTABLE_INTERFACE \
446 virtual TfWeakBase const &__GetTfWeakBase__() const { \
452 #endif // PXR_BASE_TF_WEAK_PTR_H
TfRefPtr< T > TfCreateRefPtr(T *ptr)
TfRefPtr< T > TfCreateRefPtrFromProtectedWeakPtr(TfWeakPtr< T > const &p)
TfWeakPtr & operator=(TfWeakPtr const &p)=default
Copy assignment.
TfRefPtr< Tf_Remnant >(TfWeakPtr::*) UnspecifiedBoolType
bool operator==(PtrTemplate< Other > const &p) const
bool operator!=(PtrTemplate< Other > const &p) const
decltype(_Deduce(static_cast< T * >(nullptr))) type
GLsizei const GLfloat * value
TF_API const TfNullPtrType TfNullPtr
TfWeakPtr(TfWeakPtrFacade< PtrTemplate, Type > const &wpf)
static TfRefPtr< Tf_Remnant > GetRemnant(TfWeakBase const &wb)
TfWeakPtr(std::nullptr_t)
Construction, implicit conversion from nullptr.
Y * get_pointer(TfWeakPtrFacade< X, Y > const &p)
DataType *(TfWeakPtrFacade::*)(void) const UnspecifiedBoolType
TfWeakPtr< U > TfCreateNonConstWeakPtr(U const *p)
TfWeakPtr(TfRefPtr< U > const &p, typename std::enable_if< std::is_convertible< U *, T * >::value >::type *dummy=0)
constexpr enabler dummy
An instance to use in EnableIf.
virtual TF_API void const * _GetUniqueIdentifier() const
PXR_NAMESPACE_CLOSE_SCOPE PXR_NAMESPACE_OPEN_SCOPE
#define PXR_NAMESPACE_CLOSE_SCOPE
TfWeakPtr(U *p, typename std::enable_if< std::is_convertible< U *, T * >::value >::type *dummy=nullptr)
Explicitly construct from a raw pointer p.
TfWeakPtr(TfNullPtrType)
Construction, implicit conversion from TfNullPtr.
TfWeakPtr(TfWeakPtr &&p) noexcept
Move construction.
TfWeakPtr & operator=(TfWeakPtr &&p) noexcept
Move assignment.
TfWeakPtr(TfWeakPtr< U > const &p, typename std::enable_if< std::is_convertible< U *, T * >::value >::type *dummy=0)
TfWeakBase const * GetWeakBase() const
virtual TF_API void EnableNotification() const
TfWeakPtr< U > TfCreateWeakPtr(U *p)
TfWeakPtr(TfWeakPtr< U > const &wp)