codekingpro/portable-devtools
114k
1// -*- C++ -*-2//===----------------------------------------------------------------------===//3//4// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.5// See https://llvm.org/LICENSE.txt for license information.6// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception7// SPDX-FileCopyrightText: Copyright (c) 2023 NVIDIA CORPORATION & AFFILIATES.8// SPDX-FileCopyrightText: Copyright (c) 2023 Microsoft Corporation.9//10//===----------------------------------------------------------------------===//11 12#ifndef _LIBCUDACXX___ITERATOR_UNREACHABLE_SENTINEL_H13#define _LIBCUDACXX___ITERATOR_UNREACHABLE_SENTINEL_H14 15#ifndef __cuda_std__16#include <__config>17#endif // __cuda_std__18 19#include "../__iterator/concepts.h"20 21#if defined(_CCCL_IMPLICIT_SYSTEM_HEADER_GCC)22# pragma GCC system_header23#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_CLANG)24# pragma clang system_header25#elif defined(_CCCL_IMPLICIT_SYSTEM_HEADER_MSVC)26# pragma system_header27#endif // no system header28 29#if _LIBCUDACXX_STD_VER > 1430 31_LIBCUDACXX_BEGIN_NAMESPACE_STD32_LIBCUDACXX_BEGIN_NAMESPACE_RANGES_ABI33 34// MSVC requires an interesting workaround for a /permissive- bug35// We cannot simply define unreachable_sentinel_t with it friendfunctions,36// but we must derive from a base class in a different namespace so that they37// are only ever found through ADL38 39struct unreachable_sentinel_t40#ifdef _LIBCUDACXX_COMPILER_MSVC41 ;42namespace __unreachable_sentinel_detail {43struct __unreachable_base44#endif // _LIBCUDACXX_COMPILER_MSVC45{46 _LIBCUDACXX_TEMPLATE(class _Iter)47 _LIBCUDACXX_REQUIRES(weakly_incrementable<_Iter>)48 _LIBCUDACXX_HIDE_FROM_ABI49 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_NODISCARD_FRIEND constexpr bool50 operator==(const unreachable_sentinel_t &, const _Iter &) noexcept {51 return false;52 }53#if _LIBCUDACXX_STD_VER < 2054 _LIBCUDACXX_TEMPLATE(class _Iter)55 _LIBCUDACXX_REQUIRES(weakly_incrementable<_Iter>)56 _LIBCUDACXX_HIDE_FROM_ABI57 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_NODISCARD_FRIEND constexpr bool58 operator==(const _Iter &, const unreachable_sentinel_t &) noexcept {59 return false;60 }61 _LIBCUDACXX_TEMPLATE(class _Iter)62 _LIBCUDACXX_REQUIRES(weakly_incrementable<_Iter>)63 _LIBCUDACXX_HIDE_FROM_ABI64 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_NODISCARD_FRIEND constexpr bool65 operator!=(const unreachable_sentinel_t &, const _Iter &) noexcept {66 return true;67 }68 _LIBCUDACXX_TEMPLATE(class _Iter)69 _LIBCUDACXX_REQUIRES(weakly_incrementable<_Iter>)70 _LIBCUDACXX_HIDE_FROM_ABI71 _LIBCUDACXX_INLINE_VISIBILITY _LIBCUDACXX_NODISCARD_FRIEND constexpr bool72 operator!=(const _Iter &, const unreachable_sentinel_t &) noexcept {73 return true;74 }75#endif // _LIBCUDACXX_STD_VER < 2076};77 78#ifdef _LIBCUDACXX_COMPILER_MSVC79} // namespace __unreachable_sentinel_detail80struct unreachable_sentinel_t81 : __unreachable_sentinel_detail::__unreachable_base {};82#endif // _LIBCUDACXX_COMPILER_MSVC83 84_LIBCUDACXX_END_NAMESPACE_RANGES_ABI85 86_LIBCUDACXX_CPO_ACCESSIBILITY unreachable_sentinel_t unreachable_sentinel{};87_LIBCUDACXX_END_NAMESPACE_STD88 89#endif // _LIBCUDACXX_STD_VER > 1490 91#endif // _LIBCUDACXX___ITERATOR_UNREACHABLE_SENTINEL_H92 