================ @@ -0,0 +1,95 @@ +//===----------------------------------------------------------------------===// +// +// 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 difference_type index() const noexcept; + +#include <array> +#include <cassert> +#include <concepts> +#include <cstdint> +#include <utility> +#include <tuple> + +#include "test_iterators.h" +#include "test_macros.h" +#include "../types.h" + +template <class Iterator, class ValueType = int, class Sentinel = sentinel_wrapper<Iterator>> +constexpr void test() { + using View = MinimalView<Iterator, Sentinel>; + using EnumerateView = std::ranges::enumerate_view<View>; + + std::array array{0, 1, 2, 3, 4, 5, 6, 7, 8, 9}; + + View view{Iterator(array.begin()), Sentinel(Iterator(array.end()))}; + EnumerateView ev(std::move(view)); + + { + auto it = ev.begin(); + ASSERT_NOEXCEPT(it.index()); + + static_assert(std::same_as<typename decltype(it)::difference_type, decltype(it.index())>); + for (std::size_t index = 0; index < array.size(); ++index) { + assert(std::cmp_equal(index, it.index())); + + ++it; + } ---------------- cjdb wrote:
Please hand-roll. https://github.com/llvm/llvm-project/pull/73617 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits