Implementation of Intrusive Pointer. A smart pointer that points to an object with an embedded reference counter. The underlying object must implement a friend function IntrusivePtrRefCount() that returns the ref counter (of type IntrusivePtrCell). The intrusive pointer is faster than std::shared_ptr<>: std::shared_ptr<> makes an extra memory allocation for the ref counter whereas the intrusive pointer does not.
More...
template<typename T>
class xgboost::IntrusivePtr< T >
Implementation of Intrusive Pointer. A smart pointer that points to an object with an embedded reference counter. The underlying object must implement a friend function IntrusivePtrRefCount() that returns the ref counter (of type IntrusivePtrCell). The intrusive pointer is faster than std::shared_ptr<>: std::shared_ptr<> makes an extra memory allocation for the ref counter whereas the intrusive pointer does not.
class ForIntrusivePtrTest {
public:
mutable class IntrusivePtrCell ref;
float data { 0 };
friend IntrusivePtrCell &
return t->ref;
}
ForIntrusivePtrTest() = default;
ForIntrusivePtrTest(float a, int32_t b) : data{a + static_cast<float>(b)} {}
explicit ForIntrusivePtrTest(NotCopyConstructible a) : data{a.data} {}
};
IntrusivePtr<ForIntrusivePtrTest> ptr {new ForIntrusivePtrTest};
IntrusivePtrCell & IntrusivePtrRefCount(T const *ptr) noexcept
User defined function for returning embedded reference count.