[libc-commits] [clang-tools-extra] [libcxx] [libunwind] [lldb] [clang] [compiler-rt] [libc] [flang] [llvm] [libc++] Implement ranges::iota (PR #68494)

Nikolas Klauser via libc-commits libc-commits at lists.llvm.org
Fri Jan 5 02:29:55 PST 2024


================
@@ -0,0 +1,123 @@
+//===----------------------------------------------------------------------===//
+//
+// 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
+//
+//===----------------------------------------------------------------------===//
+
+// Testing std::ranges::iota
+
+// UNSUPPORTED: c++03, c++11, c++14, c++17, c++20
+
+#include <cassert>
+#include <numeric>
+#include <algorithm>
+#include <array>
+
+#include "test_macros.h"
+#include "test_iterators.h"
+#include "almost_satisfies_types.h"
+
+// Concepts to check different overloads of std::ranges::iota
+template <class Iter = int*, class Sent = int*, class Value = int>
+concept HasIotaIter = requires(Iter&& iter, Sent&& sent, Value&& val) {
+  std::ranges::iota(std::forward<Iter>(iter), std::forward<Sent>(sent), std::forward<Value>(val));
+};
+
+template <class Range, class Value = int>
+concept HasIotaRange =
+    requires(Range&& range, Value&& val) { std::ranges::iota(std::forward<Range>(range), std::forward<Value>(val)); };
+
+constexpr void test_constraints() {
----------------
philnik777 wrote:

These test don't need to be inside a function. You can just put them at global scope. Otherwise they look really nice.

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


More information about the libc-commits mailing list