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

Mark de Wever via libcxx-commits libcxx-commits at lists.llvm.org
Sun Aug 18 06:20:50 PDT 2024


================
@@ -0,0 +1,112 @@
+//===----------------------------------------------------------------------===//
+//
+// 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 <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())); }
+
+private:
+  std::vector<int> data_ = {0, 1, 2, 3};
+};
+
+template <class Range, class Allocator>
+constexpr bool test_range() {
+  Range r;
+
+  using elements_of_t = std::ranges::elements_of<Range&, Allocator>;
+  {
+    // constructor
+    std::same_as<elements_of_t> decltype(auto) elements_of                 = std::ranges::elements_of(r, Allocator());
----------------
mordante wrote:

@EricWF do you know the answer to the question above?

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


More information about the libcxx-commits mailing list