v8 10.2.154 (node 18.16.0)
V8 is Google's open source JavaScript engine
Loading...
Searching...
No Matches
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

template<typename T >
using IsGarbageCollectedTypeMarker = void

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

◆ ParentMostGarbageCollectedType

template<typename T >
using ParentMostGarbageCollectedType = T

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

Constructor & Destructor Documentation

◆ GarbageCollected()

template<typename T >
GarbageCollected ( )
protecteddefault

Member Function Documentation

◆ operator delete()

template<typename T >
void operator delete ( void *  )
inline

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

References cppgc::internal::Fatal().

◆ operator delete[]()

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

◆ operator new()

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

◆ operator new[]()

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

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