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
static constexpr FinalizationCallback kCallback
static constexpr bool HasFinalizer()
static void Finalize(void *obj)
static void Finalize(void *obj)