v8  9.4.146 (node 16.13.0)
V8 is Google's open source JavaScript engine
GarbageCollected< T > Class Template Reference

#include <garbage-collected.h>

Inheritance diagram for GarbageCollected< T >:
Collaboration diagram for GarbageCollected< T >:

Public Types

using IsGarbageCollectedTypeMarker = void
 
using ParentMostGarbageCollectedType = T
 

Protected Member Functions

 GarbageCollected ()=default
 
- Protected Member Functions inherited from GarbageCollectedBase
 GarbageCollectedBase ()=default
 

Additional Inherited Members

- Public Member Functions inherited from GarbageCollectedBase
void * operator new (size_t)=delete
 
void * operator new[] (size_t)=delete
 
void operator delete (void *)
 
void operator delete[] (void *)=delete
 

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 77 of file garbage-collected.h.

Member Typedef Documentation

◆ IsGarbageCollectedTypeMarker

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

◆ ParentMostGarbageCollectedType

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

Constructor & Destructor Documentation

◆ GarbageCollected()

GarbageCollected ( )
protecteddefault

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