chromium/v8/include/cppgc/internal/finalizer-trait.h

// Copyright 2020 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_
#define INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_

#include <type_traits>

#include "cppgc/type-traits.h"

namespace cppgc {
namespace internal {

FinalizationCallback;

template <typename T, typename = void>
struct HasFinalizeGarbageCollectedObject : std::false_type {};

HasFinalizeGarbageCollectedObject<T, std::void_t<decltype(std::declval<T>().FinalizeGarbageCollectedObject())>>;

// The FinalizerTraitImpl specifies how to finalize objects.
template <typename T, bool isFinalized>
struct FinalizerTraitImpl;

FinalizerTraitImpl<T, true>;

FinalizerTraitImpl<T, false>;

// The FinalizerTrait is used to determine if a type requires finalization and
// what finalization means.
template <typename T>
struct FinalizerTrait {};

template <typename T>
constexpr FinalizationCallback FinalizerTrait<T>::kCallback;

}  // namespace internal
}  // namespace cppgc

#endif  // INCLUDE_CPPGC_INTERNAL_FINALIZER_TRAIT_H_