summaryrefslogtreecommitdiff
path: root/libcxx/include/__iterator
diff options
context:
space:
mode:
authorzoecarver <z.zoelec2@gmail.com>2021-08-11 11:16:27 -0700
committerzoecarver <z.zoelec2@gmail.com>2021-08-12 10:11:27 -0700
commit4ac87e33785eaaed8a41d4880075ff346fab8a0d (patch)
tree77b09f417cc359a483d2a54e9910b7ae68c8a938 /libcxx/include/__iterator
parent79fbddbea0c6940587acf5353af4557ee9524bbe (diff)
downloadllvm-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.h38
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