v8  9.0.257(node16.0.0)
V8 is Google's open source JavaScript engine
GarbageCollected< typename > Class Template Reference

#include <garbage-collected.h>

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

Public Types

using IsGarbageCollectedTypeMarker = void
 

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>
class cppgc::GarbageCollected< typename >

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.

Constructor & Destructor Documentation

◆ GarbageCollected()

GarbageCollected ( )
protecteddefault

The documentation for this class was generated from the following file:
cppgc::GarbageCollected::GarbageCollected
GarbageCollected()=default
cppgc::Visitor
Definition: visitor.h:52