5#ifndef INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
6#define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
17template <
typename T,
typename =
void>
23 std::void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>
27template <
typename T,
bool isFinalized>
35 static void Call(
void* obj) {
36 static_cast<T*
>(obj)->FinalizeGarbageCollectedObject();
42 static void Call(
void* obj) {
static_cast<T*
>(obj)->~T(); }
46 std::conditional_t<HasFinalizeGarbageCollectedObject<T>::value, Custom,
51 static_assert(
sizeof(T),
"T must be fully defined");
52 FinalizeImpl::Call(obj);
59 static_assert(
sizeof(T),
"T must be fully defined");
71 static constexpr bool kNonTrivialFinalizer =
73 !std::is_trivially_destructible<typename std::remove_cv<T>::type>::value;
75 static void Finalize(
void* obj) {
80 static constexpr bool HasFinalizer() {
return kNonTrivialFinalizer; }
84 kNonTrivialFinalizer ? Finalize :
nullptr;
void(*)(void *) FinalizationCallback
Definition: finalizer-trait.h:15
Definition: allocation.h:38
static void Finalize(void *obj)
Definition: finalizer-trait.h:58
static void Finalize(void *obj)
Definition: finalizer-trait.h:50
Definition: finalizer-trait.h:28
Definition: finalizer-trait.h:66
static constexpr FinalizationCallback kCallback
Definition: finalizer-trait.h:83
static constexpr bool HasFinalizer()
Definition: finalizer-trait.h:80
Definition: finalizer-trait.h:18