/src/node/deps/v8/include/cppgc/sentinel-pointer.h
Line | Count | Source (jump to first uncovered line) |
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_SENTINEL_POINTER_H_ |
6 | | #define INCLUDE_CPPGC_SENTINEL_POINTER_H_ |
7 | | |
8 | | #include <cstdint> |
9 | | |
10 | | #include "cppgc/internal/api-constants.h" |
11 | | |
12 | | namespace cppgc { |
13 | | namespace internal { |
14 | | |
15 | | // Special tag type used to denote some sentinel member. The semantics of the |
16 | | // sentinel is defined by the embedder. |
17 | | struct SentinelPointer { |
18 | | #if defined(CPPGC_POINTER_COMPRESSION) |
19 | | static constexpr intptr_t kSentinelValue = |
20 | | 1 << api_constants::kPointerCompressionShift; |
21 | | #else // !defined(CPPGC_POINTER_COMPRESSION) |
22 | | static constexpr intptr_t kSentinelValue = 0b10; |
23 | | #endif // !defined(CPPGC_POINTER_COMPRESSION) |
24 | | template <typename T> |
25 | 0 | operator T*() const { |
26 | 0 | return reinterpret_cast<T*>(kSentinelValue); |
27 | 0 | } Unexecuted instantiation: cppgc::internal::SentinelPointer::operator void const*<void const>() const Unexecuted instantiation: cppgc::internal::SentinelPointer::operator void*<void>() const |
28 | | // Hidden friends. |
29 | 0 | friend bool operator==(SentinelPointer, SentinelPointer) { return true; } |
30 | 0 | friend bool operator!=(SentinelPointer, SentinelPointer) { return false; } |
31 | | }; |
32 | | |
33 | | } // namespace internal |
34 | | |
35 | | constexpr internal::SentinelPointer kSentinelPointer; |
36 | | |
37 | | } // namespace cppgc |
38 | | |
39 | | #endif // INCLUDE_CPPGC_SENTINEL_POINTER_H_ |