Loading...
Searching...
No Matches
object-size-trait.h
Go to the documentation of this file.
1// Copyright 2021 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_OBJECT_SIZE_TRAIT_H_
6#define INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
7
8#include <cstddef>
9
10#include "cppgc/type-traits.h"
11#include "v8config.h" // NOLINT(build/include_directory)
12
13namespace cppgc {
14
15namespace internal {
16
18 protected:
19 static size_t GetObjectSizeForGarbageCollected(const void*);
20 static size_t GetObjectSizeForGarbageCollectedMixin(const void*);
21};
22
23} // namespace internal
24
25namespace subtle {
26
32template <typename T, bool = IsGarbageCollectedMixinTypeV<T>>
34
35template <typename T>
37 static_assert(sizeof(T), "T must be fully defined");
38 static_assert(IsGarbageCollectedTypeV<T>,
39 "T must be of type GarbageCollected or GarbageCollectedMixin");
40
41 static size_t GetSize(const T& object) {
42 return GetObjectSizeForGarbageCollected(&object);
43 }
44};
45
46template <typename T>
48 static_assert(sizeof(T), "T must be fully defined");
49
50 static size_t GetSize(const T& object) {
51 return GetObjectSizeForGarbageCollectedMixin(&object);
52 }
53};
54
55} // namespace subtle
56} // namespace cppgc
57
58#endif // INCLUDE_CPPGC_OBJECT_SIZE_TRAIT_H_
Definition: allocation.h:38
Definition: object-size-trait.h:17
static size_t GetObjectSizeForGarbageCollected(const void *)
static size_t GetObjectSizeForGarbageCollectedMixin(const void *)
static size_t GetSize(const T &object)
Definition: object-size-trait.h:41
static size_t GetSize(const T &object)
Definition: object-size-trait.h:50
Definition: object-size-trait.h:33
#define V8_EXPORT
Definition: v8config.h:762