Loading...
Searching...
No Matches
garbage-collected.h
Go to the documentation of this file.
1// Copyright 2020 the V8 project authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
6#define INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
7
9#include "cppgc/platform.h"
10#include "cppgc/trace-trait.h"
11#include "cppgc/type-traits.h"
12
13namespace cppgc {
14
15class Visitor;
16
52template <typename T>
54 public:
57
58 // Must use MakeGarbageCollected.
59 void* operator new(size_t) = delete;
60 void* operator new[](size_t) = delete;
61 // The garbage collector is taking care of reclaiming the object. Also,
62 // virtual destructor requires an unambiguous, accessible 'operator delete'.
63 void operator delete(void*) {
64#ifdef V8_ENABLE_CHECKS
66 "Manually deleting a garbage collected object is not allowed");
67#endif // V8_ENABLE_CHECKS
68 }
69 void operator delete[](void*) = delete;
70
71 protected:
72 GarbageCollected() = default;
73};
74
94 public:
96
97 // Must use MakeGarbageCollected.
98 void* operator new(size_t) = delete;
99 void* operator new[](size_t) = delete;
100 // The garbage collector is taking care of reclaiming the object.
101 // Not override the non-array varaint of `delete` to not conflict with the
102 // operator in GarbageCollected above.
103 void operator delete[](void*) = delete;
104
109 virtual void Trace(cppgc::Visitor*) const {}
110};
111
112} // namespace cppgc
113
114#endif // INCLUDE_CPPGC_GARBAGE_COLLECTED_H_
Definition: garbage-collected.h:93
void IsGarbageCollectedMixinTypeMarker
Definition: garbage-collected.h:95
virtual void Trace(cppgc::Visitor *) const
Definition: garbage-collected.h:109
Definition: garbage-collected.h:53
void IsGarbageCollectedTypeMarker
Definition: garbage-collected.h:55
T ParentMostGarbageCollectedType
Definition: garbage-collected.h:56
Definition: visitor.h:56
void Fatal(const std::string &reason=std::string(), const SourceLocation &=SourceLocation::Current())
Definition: allocation.h:38