summaryrefslogtreecommitdiff
path: root/chromium/base/util/ranges/iterator.h
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/base/util/ranges/iterator.h')
-rw-r--r--chromium/base/util/ranges/iterator.h40
1 files changed, 40 insertions, 0 deletions
diff --git a/chromium/base/util/ranges/iterator.h b/chromium/base/util/ranges/iterator.h
new file mode 100644
index 00000000000..daaedbc285b
--- /dev/null
+++ b/chromium/base/util/ranges/iterator.h
@@ -0,0 +1,40 @@
+// Copyright 2020 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef BASE_UTIL_RANGES_ITERATOR_H_
+#define BASE_UTIL_RANGES_ITERATOR_H_
+
+#include <iterator>
+
+namespace util {
+namespace ranges {
+
+// Simplified implementation of C++20's std::ranges::begin.
+// As opposed to std::ranges::begin, this implementation does not prefer a
+// member begin() over a free standing begin(), does not check whether begin()
+// returns an iterator, does not inhibit ADL and is not constexpr.
+//
+// Reference: https://wg21.link/range.access.begin
+template <typename Range>
+decltype(auto) begin(Range&& range) {
+ using std::begin;
+ return begin(std::forward<Range>(range));
+}
+
+// Simplified implementation of C++20's std::ranges::end.
+// As opposed to std::ranges::end, this implementation does not prefer a
+// member end() over a free standing end(), does not check whether end()
+// returns an iterator, does not inhibit ADL and is not constexpr.
+//
+// Reference: - https://wg21.link/range.access.end
+template <typename Range>
+decltype(auto) end(Range&& range) {
+ using std::end;
+ return end(std::forward<Range>(range));
+}
+
+} // namespace ranges
+} // namespace util
+
+#endif // BASE_UTIL_RANGES_ITERATOR_H_