[libcxx-commits] [libcxx] [libc++][ranges] implement `ranges::elements_of` (PR #91414)

Casey Carter via libcxx-commits libcxx-commits at lists.llvm.org
Mon Oct 7 20:20:40 PDT 2024


================
@@ -0,0 +1,111 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+// std::ranges::elements_of;
+
+#include <ranges>
+
+#include <concepts>
+#include <memory>
+#include <type_traits>
+#include <vector>
+
+#include "min_allocator.h"
+#include "test_allocator.h"
+#include "test_iterators.h"
+
+template <class Iterator>
+struct Range {
+  using Sentinel = sentinel_wrapper<Iterator>;
+
+  Iterator begin() { return Iterator(data_.data()); }
+
+  sentinel_wrapper<Iterator> end() { return Sentinel(Iterator(data_.data() + data_.size())); }
----------------
CaseyCarter wrote:

Seems like we could use the alias here to simplify:
```suggestion
  Sentinel end() { return Sentinel(Iterator(data_.data() + data_.size())); }
```

https://github.com/llvm/llvm-project/pull/91414


More information about the libcxx-commits mailing list