[flang-commits] [libcxx] [compiler-rt] [clang] [llvm] [clang-tools-extra] [flang] [lld] [libc++][ranges] P2116R9: Implements `views::enumerate` (PR #73617)

Christopher Di Bella via flang-commits flang-commits at lists.llvm.org
Tue Jan 2 14:17:02 PST 2024


================
@@ -0,0 +1,138 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+
+// <ranges>
+
+// class enumerate_view
+
+// class enumerate_view::iterator
+
+// constexpr const iterator_t<Base>& base() const & noexcept;
+// constexpr iterator_t<Base> base() &&;
+
+#include <ranges>
+
+#include <array>
+#include <cassert>
+#include <concepts>
+#include <utility>
+#include <tuple>
+
+#include "test_iterators.h"
+#include "../types.h"
+
+// template <class It, class ItTraits = It>
+// class MovableIterator {
+//   using Traits = std::iterator_traits<ItTraits>;
+//   It it_;
+
+//   template <class U, class T>
+//   friend class MovableIterator;
+
+// public:
+//   using iterator_category = std::input_iterator_tag;
+//   using value_type        = typename Traits::value_type;
+//   using difference_type   = typename Traits::difference_type;
+//   using pointer           = It;
+//   using reference         = typename Traits::reference;
+
+//   TEST_CONSTEXPR explicit MovableIterator(It it) : it_(it), justInitialized{true} { static_assert(false); }
+
+//   template <class U, class T>
+//   TEST_CONSTEXPR MovableIterator(const MovableIterator<U, T>& u) : it_(u.it_), wasCopyInitialized{true} {
+//     static_assert(false);
+//   }
+
+//   template <class U, class T, class = typename std::enable_if<std::is_default_constructible<U>::value>::type>
+//   TEST_CONSTEXPR_CXX14 MovableIterator(MovableIterator<U, T>&& u) : it_(u.it_), wasMoveInitialized{true} {
+//     static_assert(false);
+//     u.it_ = U();
+//   }
+
+//   TEST_CONSTEXPR reference operator*() const { return *it_; }
+
+//   TEST_CONSTEXPR_CXX14 MovableIterator& operator++() {
+//     ++it_;
+//     return *this;
+//   }
+//   TEST_CONSTEXPR_CXX14 MovableIterator operator++(int) { return MovableIterator(it_++); }
+
+//   friend TEST_CONSTEXPR bool operator==(const MovableIterator& x, const MovableIterator& y) { return x.it_ == y.it_; }
+//   friend TEST_CONSTEXPR bool operator!=(const MovableIterator& x, const MovableIterator& y) { return x.it_ != y.it_; }
+
+//   friend TEST_CONSTEXPR It base(const MovableIterator& i) { return i.it_; }
+
+//   template <class T>
+//   void operator,(T const&) = delete;
+
+//   bool justInitialized    = false;
+//   bool wasCopyInitialized = false;
+//   bool wasMoveInitialized = false;
+// };
----------------
cjdb wrote:

```suggestion
```
Please delete this if it's not being used.

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


More information about the flang-commits mailing list