Loading...
Searching...
No Matches
Public Types | Public Member Functions | Protected Member Functions | List of all members
cppgc::GarbageCollected< T > Class Template Reference

#include <garbage-collected.h>

Public Types

using IsGarbageCollectedTypeMarker = void
 
using ParentMostGarbageCollectedType = T
 

Public Member Functions

void * operator new (size_t)=delete
 
void * operator new[] (size_t)=delete
 
void operator delete (void *)
 
void operator delete[] (void *)=delete
 

Protected Member Functions

 GarbageCollected ()=default
 

Detailed Description

template<typename T>
class cppgc::GarbageCollected< T >

Base class for managed objects. Only descendent types of GarbageCollected can be constructed using MakeGarbageCollected(). Must be inherited from as left-most base class.

Types inheriting from GarbageCollected must provide a method of signature void Trace(cppgc::Visitor*) const that dispatchs all managed pointers to the visitor and delegates to garbage-collected base classes. The method must be virtual if the type is not directly a child of GarbageCollected and marked as final.

// Example using final class.
class FinalType final : public GarbageCollected<FinalType> {
public:
void Trace(cppgc::Visitor* visitor) const {
// Dispatch using visitor->Trace(...);
}
};
// Example using non-final base class.
class NonFinalBase : public GarbageCollected<NonFinalBase> {
public:
virtual void Trace(cppgc::Visitor*) const {}
};
class FinalChild final : public NonFinalBase {
public:
void Trace(cppgc::Visitor* visitor) const final {
// Dispatch using visitor->Trace(...);
NonFinalBase::Trace(visitor);
}
};
Definition: garbage-collected.h:53
Definition: visitor.h:56

Member Typedef Documentation

◆ IsGarbageCollectedTypeMarker

template<typename T >
using cppgc::GarbageCollected< T >::IsGarbageCollectedTypeMarker = void

◆ ParentMostGarbageCollectedType

template<typename T >
using cppgc::GarbageCollected< T >::ParentMostGarbageCollectedType = T

Constructor & Destructor Documentation

◆ GarbageCollected()

template<typename T >
cppgc::GarbageCollected< T >::GarbageCollected ( )
protecteddefault

Member Function Documentation

◆ operator delete()

template<typename T >
void cppgc::GarbageCollected< T >::operator delete ( void *  )
inline
Here is the call graph for this function:

◆ operator delete[]()

template<typename T >
void cppgc::GarbageCollected< T >::operator delete[] ( void *  )
delete

◆ operator new()

template<typename T >
void * cppgc::GarbageCollected< T >::operator new ( size_t  )
delete

◆ operator new[]()

template<typename T >
void * cppgc::GarbageCollected< T >::operator new[] ( size_t  )
delete

The documentation for this class was generated from the following file: