Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-22 10:42:26

0001 // Copyright 2021 the V8 project authors. All rights reserved.
0002 // Use of this source code is governed by a BSD-style license that can be
0003 // found in the LICENSE file.
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 // Special tag type used to denote some sentinel member. The semantics of the
0016 // sentinel is defined by the embedder.
0017 struct SentinelPointer {
0018 #if defined(CPPGC_POINTER_COMPRESSION)
0019   static constexpr intptr_t kSentinelValue =
0020       1 << api_constants::kPointerCompressionShift;
0021 #else   // !defined(CPPGC_POINTER_COMPRESSION)
0022   static constexpr intptr_t kSentinelValue = 0b10;
0023 #endif  // !defined(CPPGC_POINTER_COMPRESSION)
0024   template <typename T>
0025   operator T*() const {
0026     return reinterpret_cast<T*>(kSentinelValue);
0027   }
0028   // Hidden friends.
0029   friend bool operator==(SentinelPointer, SentinelPointer) { return true; }
0030   friend bool operator!=(SentinelPointer, SentinelPointer) { return false; }
0031 };
0032 
0033 }  // namespace internal
0034 
0035 constexpr internal::SentinelPointer kSentinelPointer;
0036 
0037 }  // namespace cppgc
0038 
0039 #endif  // INCLUDE_CPPGC_SENTINEL_POINTER_H_