v8  10.1.124 (node 18.2.0)
V8 is Google's open source JavaScript engine
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 at line 53 of file garbage-collected.h.

Member Typedef Documentation

◆ IsGarbageCollectedTypeMarker

Definition at line 55 of file garbage-collected.h.

◆ ParentMostGarbageCollectedType

Definition at line 56 of file garbage-collected.h.

Constructor & Destructor Documentation

◆ GarbageCollected()

GarbageCollected ( )
protecteddefault

Member Function Documentation

◆ operator delete()

void operator delete ( void *  )
inline

Definition at line 63 of file garbage-collected.h.

◆ operator delete[]()

void operator delete[] ( void *  )
delete

◆ operator new()

void* operator new ( size_t  )
delete

◆ operator new[]()

void* operator new[] ( size_t  )
delete

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