diff options
author | zoecarver <z.zoelec2@gmail.com> | 2021-08-11 11:16:27 -0700 |
---|---|---|
committer | zoecarver <z.zoelec2@gmail.com> | 2021-08-12 10:11:27 -0700 |
commit | 4ac87e33785eaaed8a41d4880075ff346fab8a0d (patch) | |
tree | 77b09f417cc359a483d2a54e9910b7ae68c8a938 /libcxx/include/__iterator | |
parent | 79fbddbea0c6940587acf5353af4557ee9524bbe (diff) | |
download | llvm-4ac87e33785eaaed8a41d4880075ff346fab8a0d.tar.gz |
[libcxx][ranges] Add `unreachable_sentinel`.
Differential Revision: https://reviews.llvm.org/D107920
Diffstat (limited to 'libcxx/include/__iterator')
-rw-r--r-- | libcxx/include/__iterator/unreachable_sentinel.h | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/libcxx/include/__iterator/unreachable_sentinel.h b/libcxx/include/__iterator/unreachable_sentinel.h new file mode 100644 index 000000000000..cbbccd7bb288 --- /dev/null +++ b/libcxx/include/__iterator/unreachable_sentinel.h @@ -0,0 +1,38 @@ +// -*- C++ -*- +//===----------------------------------------------------------------------===// +// +// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions. +// See https://llvm.org/LICENSE.txt for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//===----------------------------------------------------------------------===// + +#ifndef _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H +#define _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H + +#include <__config> +#include <__iterator/concepts.h> + +#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER) +#pragma GCC system_header +#endif + +_LIBCPP_BEGIN_NAMESPACE_STD + +#if !defined(_LIBCPP_HAS_NO_RANGES) + +struct unreachable_sentinel_t { + template<weakly_incrementable _Iter> + _LIBCPP_HIDE_FROM_ABI + friend constexpr bool operator==(unreachable_sentinel_t, const _Iter&) noexcept { + return false; + } +}; + +inline constexpr unreachable_sentinel_t unreachable_sentinel{}; + +#endif // !defined(_LIBCPP_HAS_NO_RANGES) + +_LIBCPP_END_NAMESPACE_STD + +#endif // _LIBCPP___ITERATOR_UNREACHABLE_SENTINEL_H |