File indexing completed on 2025-02-22 10:42:26
0001
0002
0003
0004
0005 #ifndef INCLUDE_CPPGC_SENTINEL_POINTER_H_
0006 #define INCLUDE_CPPGC_SENTINEL_POINTER_H_
0007
0008 #include <cstdint>
0009
0010 #include "cppgc/internal/api-constants.h"
0011
0012 namespace cppgc {
0013 namespace internal {
0014
0015
0016
0017 struct SentinelPointer {
0018 #if defined(CPPGC_POINTER_COMPRESSION)
0019 static constexpr intptr_t kSentinelValue =
0020 1 << api_constants::kPointerCompressionShift;
0021 #else
0022 static constexpr intptr_t kSentinelValue = 0b10;
0023 #endif
0024 template <typename T>
0025 operator T*() const {
0026 return reinterpret_cast<T*>(kSentinelValue);
0027 }
0028
0029 friend bool operator==(SentinelPointer, SentinelPointer) { return true; }
0030 friend bool operator!=(SentinelPointer, SentinelPointer) { return false; }
0031 };
0032
0033 }
0034
0035 constexpr internal::SentinelPointer kSentinelPointer;
0036
0037 }
0038
0039 #endif