LLVM: llvm::IntrusiveRefCntPtrInfo< T > Struct Template Reference (original) (raw)
Class you can specialize to provide custom retain/release functionality for a type. More...
template<typename T>
struct llvm::IntrusiveRefCntPtrInfo< T >
Class you can specialize to provide custom retain/release functionality for a type.
Usually specializing this class is not necessary, as IntrusiveRefCntPtr works with any type which defines Retain() and Release() functions – you can define those functions yourself if RefCountedBase doesn't work for you.
One case when you might want to specialize this type is if you have
- Foo.h defines type Foo and includes Bar.h, and
- Bar.h uses IntrusiveRefCntPtr in inline functions.
Because Foo.h includes Bar.h, Bar.h can't include Foo.h in order to pull in the declaration of Foo. Without the declaration of Foo, normally Bar.h wouldn't be able to use IntrusiveRefCntPtr, which wants to call T::Retain and T::Release.
To resolve this, Bar.h could include a third header, FooFwd.h, which forward-declares Foo and specializes IntrusiveRefCntPtrInfo. Then Bar.h could use IntrusiveRefCntPtr, although it still couldn't call any functions on Foo itself, because Foo would be an incomplete type.
Definition at line 161 of file IntrusiveRefCntPtr.h.